Reference for console commands, Lua hooks and Lua commands in CS2D.

CS2D Command CS2D Console Commands

Lua Hook Lua Hooks

Lua Command Lua Commands

Lua Command timer



  • time
  • "function"
  • ["parameter"] (optional)
  • [count] (optional)


Creates a timer which will call the Lua function "function" after a certain time in milliseconds (time). Moreover it can pass an optional string parameter ("parameter") to this function. The timer calls the function once by default. However you can call it several times by entering the optional count parameter (count). Using 0 or lower count values will make the timer call the function infinite times.

Note: Time in ms (milliseconds, 1000 ms = 1 sec)

Note: This will throw an "attempt to call a nil value" Lua error in the console when the specified function ("function") does not exist. "function" must be a string which equals the name of an existing Lua function.

Note: CS2D is single threaded and runs with a locked maximum frame rate. This means that the FPS lock also limits the precision of timers. Be aware that - depending on the FPS - timers might be executed a few milliseconds later than specified. This imprecision may also sum up when executing a timer more often (count<=0 or count>1).

Attention: Creating many timers with a high frequency (low time value) and a high/infinite count can slow down the game if the executed functions are complex. Use freetimer to remove unused timers!

Sample 1: Executing a function once with 5 secs delay and without parameter
function dothislater()
   msg("This text is displayed 5 seconds after using timer")

Sample 2: Executing a function 10 times with a 1 second delay
function tick()

Sample 3: Delayed execution with parameter
timer(3000,"delayedtext","Hi, this is displayed delayed using a timer")
function delayedtext(text)

Sample 4: Using the parse Lua function to execute CS2D commands with delay (note how ' and " are used for string encapsulation!)
timer(1000,"parse",'sv_msg "Server shutdown in 5 secs"')
timer(2000,"parse",'sv_msg "... 4 secs"')
timer(3000,"parse",'sv_msg "... 3 secs"')
timer(4000,"parse",'sv_msg "... 1 sec"')