This page contains a useful reference with console commands, Lua hooks and Lua commands in CS2D.

CS2D Command CS2D Console Commands

Lua Hook Lua Hooks

Lua Command Lua Commands

Category: all (72)

Lua Command parse



  • "commands"
  • [Stop-At-Semicolon] (optional)


Executes ordinary non-Lua CS2D commands.
Everything behind the first semicolon (;) will be ignored. This is a security measurement in case you're using user input (like chat messages) with this command. You can change this behavior by setting Stop-At-Semicolon to 0.

A list of non-Lua CS2D commands is available here!

Note: In many cases you can simply include the wrapper to use ordinary non-Lua CS2D commands like Lua functions. Take a look at sys/lua/wrapper.lua for more information! Your resulting Lua code will be much easier to read if you use the wrapper!

Attention: Many people make mistakes when using the parse command. It needs a string as parameter. This can be difficult if you want to insert Lua variables into this string or if you are working with CS2D commands that have strings as parameters. Take a look at the examples!

Attention: Be very careful when using this command with user input. Users could use quotes or semicolons to change the way the script is parsed. This can allow them to execute their own commands or to manipulate parameters. Never set Stop-At-Semicolon to 0 if you are parsing a string which contains user input!

Sample 1: Change the server name using Lua (note the usage of ' and " to encapsule the 2 different strings)
parse('sv_name "Test Server"')

Sample 2: Using an integer variable with parse (note that ".." is used to connect the variable with the string
parse('banusgn '..banid)

Sample 3: Using a string variable with parse (note that additional " are required for this case!)
parse('banname "'..username..'"')

Sample 3 might be a bit confusing at the first look but we know that ".." just connects 2 strings in Lua and we just have 3 strings here:
- 'banname "'
- username (which has the value "Player")
- and '"'
so the resulting string is just 'banname "Player"' (not 'banname ""Player""' because the " in "Player" are NOT part of the variable value! They are just used to tell Lua where the string starts and ends). This is a working CS2D command. You could enter it in the console.

Sample 4: Using multiple variables with parse
parse('setpos '..player..' '..xpos..' '..ypos)
The parameter in the code of sample 4 will be connected to the string 'setpos 1 5 3' - which works (note that parameters in CS2D console commands are separated with spaces and NOT with , like it's done in Lua!)

Take a look at the file sys/lua/wrapper.lua in your CS2D folder for more examples on how to use parse!