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!

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

On region enter

Discussion in 'Requests' started by TheRobs, Jan 29, 2017.

Tags:
  1. TheRobs

    TheRobs Member

    Joined:
    Jan 26, 2017
    Messages:
    14
    Likes Received:
    0
    Hello, I need a skript that does the following: When entering the region, if the player does not have the permission, region.enter, it will be thrown back, and will not be able to enter
     
  2. ShaneBee

    Moderator Resource Staff Supporter + Addon Developer

    Joined:
    Sep 7, 2017
    Messages:
    2,184
    Likes Received:
    220
    • Like Like x 1
  3. ShaneBee

    Moderator Resource Staff Supporter + Addon Developer

    Joined:
    Sep 7, 2017
    Messages:
    2,184
    Likes Received:
    220
  4. ShaneBee

    Moderator Resource Staff Supporter + Addon Developer

    Joined:
    Sep 7, 2017
    Messages:
    2,184
    Likes Received:
    220
    The documentation for learning how to use skript is located here:

    https://skunity.com/


    There is a search bar up the top which you can search region which will return the syntax

    on region enter: ( Now if you read the description that goes along with that it tell you that this event is fired when a player enters a region"

    If i do some more digging for permission i can see there is a syntax for checking if a player has a permission

    if player has permission "Permission.Node.here":



    then if i search for push i can see i'm able to push a player in any direction, i want to push them away from the region they're facing so simply i can push them backwards however if you use logic ( That's the brain xD ) a player could walk into the region back wards and enter it so you're going to want to then check there directional facing and push them depending on that, this bit may be a bit confusing for you however if i'm facing north then i'll be push south and if i'm facing east i'll be push west and so on and so forth, this can be achieved with basic if and else statments, so again if i search the docs for facing i can see there is syntax for checking a player's horizontal facing

    if player's horizontal facing is north:
    Push player south at speed 4

    Now since i'm a nice guy, i'll use all the knowledge i've gotten just from the docs to put this script together

    Code (Skript):
    1. on region enter:
    2.  if player has permission "region.enter":
    3.    if player's horizontal facing is north:
    4.      push player south at speed 4
    Note this is incomplete, and formatting is messed up because i've just downloaded about 9000 viruses onto my computer and they won't let me press tab or open any applications so, enjoy.
     
  5. ShaneBee

    Moderator Resource Staff Supporter + Addon Developer

    Joined:
    Sep 7, 2017
    Messages:
    2,184
    Likes Received:
    220
    Do you mind if i fix it?
     
  6. ShaneBee

    Moderator Resource Staff Supporter + Addon Developer

    Joined:
    Sep 7, 2017
    Messages:
    2,184
    Likes Received:
    220
    Can do, haha sorry, forgot about this. There's definitely a better way to do this and it's not how i'd do it but for simplicity here's some code that'll work.

    Code (Skript):
    1. on region enter:
    2.     wait 3 ticks
    3.     if player does not have permission "region.enter":
    4.         if player's horizontal facing is north:
    5.             push player south at speed 4
    6.         else if player's horizontal facing is east:
    7.             push player west at speed 4
    8.         else if player's horizontal facing is south:
    9.             push player north at speed 4
    10.         else if player's horizontal facing is west:
    11.             push player east at speed 4
    12.         message "<pink>You're not allowed in this region!"
     
  7. ShaneBee

    Moderator Resource Staff Supporter + Addon Developer

    Joined:
    Sep 7, 2017
    Messages:
    2,184
    Likes Received:
    220
    Would have to do for him not to enter the region "VIP"
     
  8. ShaneBee

    Moderator Resource Staff Supporter + Addon Developer

    Joined:
    Sep 7, 2017
    Messages:
    2,184
    Likes Received:
    220
    I don't understand what you mean, sorry?
     
  9. ShaneBee

    Moderator Resource Staff Supporter + Addon Developer

    Joined:
    Sep 7, 2017
    Messages:
    2,184
    Likes Received:
    220
    Can not make it enter the region: VIP
    (Note: My English is a bit bad)
     
  10. ShaneBee

    Moderator Resource Staff Supporter + Addon Developer

    Joined:
    Sep 7, 2017
    Messages:
    2,184
    Likes Received:
    220
    if "%region%" contains "VIP":
     
  11. ShaneBee

    Moderator Resource Staff Supporter + Addon Developer

    Joined:
    Sep 7, 2017
    Messages:
    2,184
    Likes Received:
    220
  12. 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 {region.perm::%region%} is set:
    3.         if player does not have permission "%{region.perm::%region%}%":
    4.             #push the player out of the region
    5.  
    6. command /rgperm <text> <text>:
    7.     trigger:
    8.         set {region.perm::%arg 1%} to arg 2
    This will deal with checking the permissions. However, you need to find your own way to push the player in the opposite direction, as I don't remember the exact equation to get the facing of the player and flip it depending on the location of the region.
     

Share This Page

Loading...