Avoiding region in randomtp

  • Welcome to skUnity!

    Welcome to skUnity! This is a forum where members of the Skript community can communicate and interact. Skript Resource Creators can post their Resources for all to see and use.

    If you haven't done so already, feel free to join our official Discord server to expand your level of interaction with the community!

    Now, what are you waiting for? Join the community now!

  • LOOKING FOR A VERSION OF SKRIPT?

    You can always check out skUnity Downloads for downloads and any other information about Skript!

Status
Not open for further replies.

Leon@rdo

Member
Apr 4, 2020
1
0
0
Hello!

I have skript with random teleport for players and I wonder, becuase on the server I have fraction plugin that will have regions for guild and stuff like that.

I want the skript to avoid players regions or in case stop the skript to teleport player.

Code:
options:
    min.x: -4500
    max.x: 4500
    min.z: -4500
    max.z: 4500

    avoid: air or water or lava
   
    cooldown: 4 hours
   
on sign edit:
    line 1 of event-block is "[randomtp]"
    if player has permission "jqb.randomtp.sign":
        stop
    cancel event

on click on sign:
    line 1 of event-block is "[randomtp]"
    randomTeleport(player)

command /randomtp:
    # cooldown: 4 hours
    # cooldown message: Użyłeś RTP %elapsed time% temu, ponownie możesz użyć za %remaining time%.
    # cooldown bypass: jqb.randomtp.bypass
    # cooldown storage: {randomtp.lastuse::%player%}
    aliases: /rtp, /wild, /wilderness
    trigger:
        if player's world is "Frakcje_the_end":
            send "Nie możesz tego robić w Kresie!" to {_p}
            stop
        else if player's world is "Frakcje_nether":
            send "Nie możesz tego robić w Netherze!" to {_p}
            stop
           
        send "&e&lRTP &7» Poczekaj &22 sekundy &7na teleport. Nie ruszaj się!"
       
        set {_loc} to player's location
        wait 2 seconds
        if distance between {_loc} and player's location is more than 1:
            send "&e&lRTP &7» Ruszyłeś się!"
            stop
       
        randomTeleport(player)
       
function randomTeleport(p :player):
    set {_diff} to difference between {randomtp.lastuse::%{_p}%} and now
    if {_diff} < {@cooldown}:
        set {_remain} to {@cooldown}
        remove {_diff} from {_remain}
        send "&e&lRTP &7» Użyłeś RTP &e%{_diff}% temu&7, ponownie możesz użyć za &e%{_remain}%." to {_p}
        stop
       
    set {_oldLoc} to {_p}'s location
   
    while {_p}'s location is {_oldLoc}:
        set {_location} to location at random number between {@min.x} and {@max.x}, 0, random number between {@min.z} and {@max.z} in world {_p}'s world
        loop blocks above {_location}:
            if loop-block and block above loop-block are air:
                if block under loop-block is not {@avoid}:
                    set {_location} to location of loop-block
                    set {_biome} to biome at {_location}
                    teleport {_p} to {_location}
                    apply resistance 100 to {_p} for 6 seconds
                    set {randomtp.lastuse::%{_p}%} to now
                    stop loop
        wait 10 ticks

That's the sk file skript.

I was thinking about
Code:
region at player is set: stop
but I am not sure how to do that.
[doublepost=1586881131,1586040098][/doublepost]Anyone?
 
Status
Not open for further replies.