Commands/Lua
Reference for console commands, Lua hooks and Lua commands in CS2D.
- Console Commands are entered in console, executed with key-binds, cfg-files or with Lua parse
- Lua Hooks execute Lua when events occur - some have a return value which can change the game behavior
- Lua Commands are used to retrieve game data or to perform actions in Lua scripts
CS2D Console Commands
Lua Hooks
spawn
Categories
Parameters
- id: player id
Info
Whenever a player is spawned (hook is executed once for each spawn of each player). Spawns can occur in two different situations:
You can use the return value of this hook to influence with which weapons the player will be spawned. Just return a comma-separated string with the weapon IDs. Return nothing (or an empty string) to let the player spawn with the regular items (default behavior). Return just an "x" to spawn the player with melee weapon only (depends on game mode, knife in most modes).
Weapon and item IDs:
Sample: Always spawn all players with AK-47 (30), Desert Eagle (3) and HE (51)
- On roundstart (with preceding roundstart_prespawn hook and subsequent roundstart hook)
- After death or team switching in game modes with instant respawn (like deathmatch for instance)
You can use the return value of this hook to influence with which weapons the player will be spawned. Just return a comma-separated string with the weapon IDs. Return nothing (or an empty string) to let the player spawn with the regular items (default behavior). Return just an "x" to spawn the player with melee weapon only (depends on game mode, knife in most modes).
Weapon and item IDs:
Note: Hook order when starting a new round is:
- startround_prespawn
- spawn (once for each player)
- startround
Attention: Do NEVER use the "equip" command within this hook! It will probably lead to problems! Use the return value of the hook instead!
Sample: Always spawn all players with AK-47 (30), Desert Eagle (3) and HE (51)
addhook("spawn","sampleSpawn")
function sampleSpawn()
return "30,3,51,"
end
function sampleSpawn()
return "30,3,51,"
end
Return Values
- "": (nothing) spawn with regular items
- "x": spawn with melee weapon only
- "typeid,typeid,...": spawn with these items + melee