Local variables start with {_ and only exist within their current trigger:
command /timer: trigger: set {_difference} to now - {timer} send "Time difference: %{_difference}%" # {_difference} is deleted after the command finishes
Use local variables for temporary calculations and data that doesn’t need to persist.
Global variables persist across server restarts and are accessible everywhere:
command /timer: permission: skript.example.timer trigger: if {timer} is set: send "This command was last run %time since {timer}% ago." else: send "This command has never been run." set {timer} to now
Global variables are stored in a database file. Too many variables can slow down your server.
List variables store multiple values using the ::* syntax:
# Add items to a listadd "bacon" to {_shopping list::*}add "eggs" to {_shopping list::*}add "oats" and "sugar" to {_shopping list::*}# Set specific indicesset {_items::1} to "apple"set {_items::2} to "banana"set {_items::3} to "orange"
command /shoppinglist: permission: skript.example.list trigger: add "bacon" to {_shopping list::*} add "eggs" to {_shopping list::*} add "oats" and "sugar" to {_shopping list::*} send "You have %size of {_shopping list::*}% things in your shopping list:" loop {_shopping list::*}: send "%loop-index%. %loop-value%" send "You bought some %{_shopping list::1}%!" remove "bacon" from {_shopping list::*} send "Removing bacon from your list." send "You now have %size of {_shopping list::*}% things in your shopping list."
on join: set {items::%uuid of player%::helmet} to player's helmet set {items::%uuid of player%::boots} to player's boots send "Stored your helmet and boots."command /outfit: executable by: players permission: skript.example.outfit trigger: give player {items::%uuid of player%::*} # gives the contents of the list clear {items::%uuid of player%::*} # clears this list send "Gave you the helmet and boots you joined with."
Using uuid of player ensures variables work even if a player changes their name.
if {timer} is set: send "Timer is active"else: send "Timer has never been set"if {homes::%uuid of player%::%arg-1%} is set: teleport player to {homes::%uuid of player%::%arg-1%}else: send "You have no home named <green>%arg-1%<reset>."
command /home <text> [<text>]: description: Set, delete or travel to your home. usage: /home set/remove <name>, /home <name> permission: skript.example.home executable by: players trigger: if arg-1 is "set": if arg-2 is set: set {homes::%uuid of player%::%arg-2%} to player's location send "Set your home <green>%arg-2%<reset> to <grey>%location of player%<reset>" to player else: send "You must specify a name for this home." to player else if arg-1 is "remove": if arg-2 is set: delete {homes::%uuid of player%::%arg-2%} send "Deleted your home <green>%arg-2%<reset>" to player else: send "You must specify the name of this home." to player else if arg-2 is set: send "Correct usage: /home set/remove <name>" to player else if {homes::%uuid of player%::%arg-1%} is set: teleport player to {homes::%uuid of player%::%arg-1%} else: send "You have no home named <green>%arg-1%<reset>." to player
on damage: victim is a player if the victim has permission "skript.example.damage": cancel the event else: send "Ouch! You took %damage% damage." to the victim add damage to {damage::%uuid of victim%::taken} if the attacker is a player: add damage to {damage::%uuid of attacker%::dealt}
command /shoppinglist: permission: skript.example.list trigger: add "bacon" to {_shopping list::*} add "eggs" to {_shopping list::*} add "oats" and "sugar" to {_shopping list::*} send "You have %size of {_shopping list::*}% things in your shopping list:" loop {_shopping list::*}: send "%loop-index%. %loop-value%" send "You bought some %{_shopping list::1}%!" remove "bacon" from {_shopping list::*} send "Removing bacon from your list." send "You now have %size of {_shopping list::*}% things in your shopping list."