-
-
Notifications
You must be signed in to change notification settings - Fork 6
Region Events
Currently, skript-worldguard only supports one event: when a player enters or leaves a region. On this page, we will cover this event.
A common desire is to run code when a player enters or leaves a region. With skript-worldguard, this is a piece of cake!
The easiest way to achieve this is to just listen for any time a player enters or leaves a region. The syntax for doing so is:
region enter[ing]
region (exit[ing]|leav(e|ing))
Consider the following example that sends a simple message when a player enters a region and when they leave it:
on region enter:
message "Welcome to %name of region%" to player
on region exit:
message "Farewell from %name of region%" to player
We can view the result in game:
region_event.mp4
Of course, you might want to control when your code runs, or more specifically, for what regions. The event supports specifying what regions (and optionally what world) it should fire for:
enter[ing] of [the] [worldguard] region[s] [with [the] (name[s]|id[s])|named] %strings% [(in|of) [[the] world] %string%]
(exit[ing]|leav(e|ing)) of [the] [worldguard] region[s] [with [the] (name[s]|id[s])|named] %strings% [(in|of) [[the] world] %string%]
Consider the following script that charges a fee to enter a region:
on enter of the region named "expensive_region" in the world "world":
if the player does not have 5 gold ingots:
message "<red>It costs 5 gold ingots to enter this region!"
cancel event
else:
remove 5 gold ingots from the player's inventory
message "<green>Thank you for paying the fee!"
We can view the result in game:
expensive_region.mp4
The type of movement that led to a player entering/leaving a region is available through the movement type
expression.
For example:
on region enter:
if the movement type is swimming:
message "You have swum into %region%!"
The available movement types are
respawn, respawning, embark, embarking, move, moving, glide, gliding, swim, swimming, teleport, teleporting, teleportation, ride, riding, non cancellable, not cancellable, cancellable
Have ideas for new events? You can click here to open a new discussion.