Commands/Lua

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

CS2D Command CS2D Console Commands

Lua Hook Lua Hooks

Category: player (56)

Lua Hook 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:
  • 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:
items

Note: Hook order when starting a new round is:

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

Return Values

  • "": (nothing) spawn with regular items
  • "x": spawn with melee weapon only
  • "typeid,typeid,...": spawn with these items + melee

Lua Command Lua Commands