Solved Help with WorldGuard regions

  • 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 comminuty!

    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.

Nikola

Member
Jul 10, 2019
38
1
8
Serbia
Hello. I have been working at one project in skript and I really need your help. My idea is to send title or message when player enters worldguard region (example: region named "Spawn"). My problem is that I can't find a code for entering specified region. Is there any addon which adds region enter trigger, or code for that?

Thanks!
 
code_language.skript:
on region enter:
    if "%event-region%" contains "spawn":
        # do stuff
if that doesn't work, try this
code_language.skript:
on region enter:
    wait 1 tick
    if "%region at player%" contains "spawn":
        #do stuff
 
Hello. I have been working at one project in skript and I really need your help. My idea is to send title or message when player enters worldguard region (example: region named "Spawn"). My problem is that I can't find a code for entering specified region. Is there any addon which adds region enter trigger, or code for that?

Thanks!
As ShaneBee said, you need to check if the “%region%” string CONTAINS the region name. Now, you could ask, “why do I have to check if it contains the name instead of if it IS the name?” Well, this has to do with the way Skript writes regions, and this is what confused me at the start. You see, to get the region at the player, Skript doesn’t just get the name of the region: it writes the name and then adds a “in world” or something like that. Besides, if the player is in MULTIPLE regions, your “%region%” string will include all of them. So, at the moment, the only way to check what region the player’s in is through putting it in a string (“%region%”) and checking if it contains the desired region name (contains “regionname”).
 
As ShaneBee said, you need to check if the “%region%” string CONTAINS the region name. Now, you could ask, “why do I have to check if it contains the name instead of if it IS the name?” Well, this has to do with the way Skript writes regions, and this is what confused me at the start. You see, to get the region at the player, Skript doesn’t just get the name of the region: it writes the name and then adds a “in world” or something like that. Besides, if the player is in MULTIPLE regions, your “%region%” string will include all of them. So, at the moment, the only way to check what region the player’s in is through putting it in a string (“%region%”) and checking if it contains the desired region name (contains “regionname”).
It's actually better to loop the regions, then check if the loop-value is the correct region, since you could have a region `a` and `ab`, which both contain `a`.
 
Status
Not open for further replies.