Effects

Cancel Event

🔗

Effect

Patterns:
  • cancel [the] event
  • uncancel [the] event
Since: 1.0
Cancels the event (e.g. prevent blocks from being placed, or damage being taken).

Examples:

on damage:
    victim is a player
    victim has the permission "skript.god"
    cancel the event

Change: Set/Add/Remove/Delete/Reset

🔗

Effect

Patterns:
Since: 1.0 (set, add, remove, delete), 2.0 (remove all)
A very general effect that can change many expressions. Many expressions can only be set and/or deleted, while some can have things added to or removed from them.

Examples:

# set:
Set the player's display name to "<red>%name of player%"
set the block above the victim to lava
# add:
add 2 to the player's health # preferably use '<a href='#EffHealth'>heal</a>' for this
add argument to {blacklist::*}
give a diamond pickaxe of efficiency 5 to the player
increase the data value of the clicked block by 1
# remove:
remove 2 pickaxes from the victim
subtract 2.5 from {points::%uuid of player%}
# remove all:
remove every iron tool from the player
remove all minecarts from {entitylist::*}
# delete:
delete the block below the player
clear drops
delete {variable}
# reset:
reset walk speed of player
reset chunk at the targeted block

Continue

🔗

Effect

Patterns:
  • continue [this loop|[the] [current] loop]
  • continue [the] %*integer%(st|nd|rd|th) loop
Since: 2.2-dev37, 2.7 (while loops), 2.8.0 (outer loops)
Moves the loop to the next iteration. You may also continue an outer loop from an inner one. The loops are labelled from 1 until the current loop, starting with the outermost one.

Examples:

# Broadcast online moderators
loop all players:
    if loop-value does not have permission "moderator":
        continue # filter out non moderators
    broadcast "%loop-player% is a moderator!" # Only moderators get broadcast

# Game starting counter
set {_counter} to 11
while {_counter} > 0:
    remove 1 from {_counter}
    wait a second
    if {_counter} != 1, 2, 3, 5 or 10:
        continue # only print when counter is 1, 2, 3, 5 or 10
    broadcast "Game starting in %{_counter}% second(s)"

Copy Into Variable

🔗

Effect

Patterns:
Since: 2.8.0
Copies objects into a variable. When copying a list over to another list, the source list and its sublists are also copied over. Note: Copying a value into a variable/list will overwrite the existing data.

Examples:

set {_foo::bar} to 1
set {_foo::sublist::foobar} to "hey"
copy {_foo::*} to {_copy::*}
broadcast indices of {_copy::*} # bar, sublist
broadcast {_copy::bar} # 1
broadcast {_copy::sublist::foobar} # "hey!"

Delay

🔗

Effect

Patterns:
Since: 1.4
Delays the script's execution by a given timespan. Please note that delays are not persistent, e.g. trying to create a tempban script with ban player → wait 7 days → unban player will not work if you restart your server anytime within these 7 days. You also have to be careful even when using small delays!

Examples:

wait 2 minutes
halt for 5 minecraft hours
wait a tick

Do If

🔗

Effect

Patterns:
  • <.+> if <.+>
Since: 2.3
Execute an effect if a condition is true.

Examples:

on join:
    give a diamond to the player if the player has permission "rank.vip"

Enable/Disable/Reload Script File

🔗

Effect

Patterns:
  • ((enable|load)|reload|(disable|unload)) s(c|k)ript [file] %text%
Since: 2.4
Enables, disables, or reloads a script file.

Examples:

reload script "test"
enable script file "testing"
unload script file "script.sk"

Exit

🔗

Effect

Patterns:
  • (exit|stop) [trigger]
  • (exit|stop) [(1|a|the|this)] (section|loop|conditional)
  • (exit|stop) <\d+> (section|loop|conditional)s
  • (exit|stop) all (section|loop|conditional)s
Since: unknown (before 2.1)
Exits a given amount of loops and conditionals, or the entire trigger.

Examples:

if player has any ore:
    stop
message "%player% has no ores!"
loop blocks above the player:
    loop-block is not air:
        exit 2 sections
    set loop-block to water

Exit Program

🔗

Effect

Patterns:
  • exit (program|app|application)
  • exit (program|app|application) with code %number%
Since: 3.0
Exit the program with or without a custom exit code.

Examples:

on main:
    log "Hello World" to the console
exit program

Locally Suppress Warning

🔗

Effect

Patterns:
  • [local[ly]] suppress [the] (conflict|variable save|[missing] conjunction[s]|starting [with] expression[s]) warning[s]
Since: 2.3
Suppresses target warnings from the current script.

Examples:

locally suppress missing conjunction warnings
suppress the variable save warnings

Log

🔗

Effect

Patterns:
Since: 2.0
Writes text into a .log file. Skript will write these files to /.skript/logs. NB: Using 'server.log' as the log file will write to the default server log. Omitting the log file altogether will log the message as '[Skript] [<script>.sk] <message>' in the server log.

Examples:

on place of TNT:
    log "%player% placed TNT in %world% at %location of block%" to "tnt/placement.log"

LogToConsole

🔗

Effect

Patterns:
  • (log|write) %texts% to the (console|terminal|output|log)
Since: 3.0
Writes text to the console.

Examples:

on main:
    log "%player% placed TNT in %world% at %location of block%" to the console

Return

🔗

Effect

Patterns:
Since: 2.2, 2.8.0 (returns aliases)
Makes a function return a value

Examples:

function double(i: number) :: number:
    return 2 * {_i}

function divide(i: number) returns number:
    return {_i} / 2