escape 

$escape(string)

The escape function will escape all special characters in the string, allowing it to be safely parsed for commands. This is useful on user supplied input if it ends up being evaluated twice, such as some cases with the doas directive, or using the /eval command.

Example:


$escape() example

# On a player death with the flag, report to each member of his team where he dropped it.

on a_DroppedFlag cmd /eval foreach ($(pt)) /say_resp . Enemy flag dropped at \\\[ $loc($(pz)) \\\] by $escape($(pn)).;

# The /eval evaluates the location and player name once, instead of for each time, it ends up getting passed to
# foreach as something like (assuming a player named '$tick' dropped the flag at the Bridge):
# /say_resp . Enemy flag dropped at \[ Bridge \] by \$tick
# When /say_resp is run for each player, the escapes are evaluated and the string comes out properly. If the name
# was not escaped in this case, it would think that $tick was a variable.