1. 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!

  2. LOOKING FOR A VERSION OF SKRIPT?

    You can always check out our Wiki for downloads and any other information about Skript!

Dismiss Notice
This site uses cookies. By continuing to use this site, you are agreeing to our use of cookies. Learn More.

Solved Help with WorldGuard regions

Discussion in 'Skript' started by Nikola, Jul 10, 2019.

Thread Status:
Not open for further replies.
  1. Nikola

    Nikola Member

    Joined:
    Jul 10, 2019
    Messages:
    38
    Likes Received:
    1
    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!
     
  2. ShaneBee

    Moderator Resource Staff Supporter + Addon Developer

    Joined:
    Sep 7, 2017
    Messages:
    2,184
    Likes Received:
    220
    Code (Skript):
    1. on region enter:
    2.     if "%event-region%" contains "spawn":
    3.         # do stuff
    if that doesn't work, try this
    Code (Skript):
    1. on region enter:
    2.     wait 1 tick
    3.     if "%region at player%" contains "spawn":
    4.         #do stuff
     
    • Agree Agree x 1
  3. PatoFrango

    PatoFrango Active Member

    Joined:
    Jul 12, 2017
    Messages:
    240
    Likes Received:
    14
    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”).
     
  4. TPGamesNL

    Supporter Addon Developer Dev Programme

    Joined:
    Jan 20, 2018
    Messages:
    1,500
    Likes Received:
    107
    Medals:
    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`.
     
  5. PatoFrango

    PatoFrango Active Member

    Joined:
    Jul 12, 2017
    Messages:
    240
    Likes Received:
    14
    ^^^ Also possible
     
  6. Nikola

    Nikola Member

    Joined:
    Jul 10, 2019
    Messages:
    38
    Likes Received:
    1
    Thank you all for helping! It works :emoji_grinning:
     
    • Like Like x 1
Thread Status:
Not open for further replies.

Share This Page

Loading...