Lua hooks (Counter-Strike 2D)
This page lists all available Lua hooks in Counter-Strike 2D. For a more up-to-date version made by DC, refer to http://www.cs2d.com/help.php?hookcat=all
NOTE: This page is incomplete!
break is fired once a breakable entity is destroyed.
x, y, playerID
x, y - breakable entity position in tiles
playerID - ID of player who destroyed the breakable or 0 if it was not broken by a player
endround is executed on round end
- Note: Often, but not necessarily always, the startround hook will be triggered afterwards.
mode - specifies the type of a round end
Possible mode values:
- 1=Terrorist win (elimination)
- 2=Counter-Terrorist win (elimination)
- 3=Round draw
- 4=Game commencing
- 5=Round restart
- 10=VIP killed (as_ maps)
- 11=VIP escaped (as_ maps)
- 12=VIP did not escape (as_ maps)
- 20=Bomb detonated (de_ maps)
- 21=Bomb defused (de_ maps)
- 22=Bombsite protected (de_ maps)
- 30=Hostages protected (cs_ maps)
- 31=Hostages rescued (cs_ maps)
- 40=Blue flag captured (ctf_ maps)
- 41=Red flag captured (ctf_ maps)
- 50=All points dominated by T (dom_ maps)
- 51=All points dominated by CT (dom_ maps)
- 60=All humans killed (Zombies! game mode)
- 61=Survivors survived (Zombies! game mode)
log is executed when a text line has to be logged (console, log file).
- Attention: Do not execute any code that write text to console, e.g. using print() - it will result in an infinite loop and crash! Same applies to faulty Lua code, because Lua errors are always written to console, hence any occuring errors will hang up the application.
text - text to be written to log
- 0 - proceed normally
- 1 - don't log this line (this only affects logging, console output can not be controlled with it)
mapchange is fired when server changes the map.
newmap - name of the new map that will be loaded
parse is fired once the server parses a server-side console command.
- Note: This hook does not handle client-side commands such as radio1, slot3, left etc.
text - text to be parsed and interpreted as a command
- 0 - proceed normally
- 1 - normal parsing, ignore unknown commands
- 2 - skip CS2D parsing, CS2D will not execute this command
move is called everytime a player moves. Called at most once a frame.
- Note: It is possible that this is not triggered every frame even though the client moves constantly. This depends on the network conditions
id, x, y, walking
id (number) - player ID
x, y (number) - new player position on map in pixels
walking (number) - was the player walking (holding SHIFT)? 0 = running, 1 = walking