On region enter

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

TheRobs

Member
Jan 26, 2017
16
0
1
23
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
 
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_language.skript:
on region enter:
 if player has permission "region.enter":
   if player's horizontal facing is north:
     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.
 
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_language.skript:
on region enter:
 if player has permission "region.enter":
   if player's horizontal facing is north:
     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.
Do you mind if i fix it?
 
Do you mind if i fix it?
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_language.skript:
on region enter:
    wait 3 ticks
    if player does not have permission "region.enter":
        if player's horizontal facing is north:
            push player south at speed 4
        else if player's horizontal facing is east:
            push player west at speed 4
        else if player's horizontal facing is south:
            push player north at speed 4
        else if player's horizontal facing is west:
            push player east at speed 4
        message "<pink>You're not allowed in this region!"
 
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
code_language.skript:
on region enter:
    if {region.perm::%region%} is set:
        if player does not have permission "%{region.perm::%region%}%":
            #push the player out of the region

command /rgperm <text> <text>:
    trigger:
        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.