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
hit
Categories
Parameters
- id: player id (the victim)
- source: source player id or 0 (the attacker)
- weapon: weapon type id / special source id
- hpdmg: caused damage (health)
- apdmg: caused damage (armor)
- rawdmg: original damage without armor calculations
- object: id of dynamic object that caused the hit (or 0 if not hit by object)
Info
Whenever the player with the given id is hit/damaged.
source is the ID of the player who attacked or who built the building which attacked/caused damage.
It can also be 0 in some cases:
weapon can be a weapon type ID or a special source ID (see images below).
Often source will be 0 if the damage was caused by a special source.
In many cases you will then get the ID of the attacking object with the object parameter.
hpdmg is the value which will be subtracted from the victim's health and apdmg is the value which will be subtracted from its armor.
rawdmg is the actual raw damage which was caused by the attack without taking the armor of the victim into account.
CS2D Damage calculation (in this order):
You can ignore the hit (the victim won't suffer any damage) by returning 1.
Note that on client side you will always hit effects (e.g. blood) even when returning 1.
Weapon and item type IDs:
Special source IDs:
source is the ID of the player who attacked or who built the building which attacked/caused damage.
It can also be 0 in some cases:
- the environment/map/an entity caused damage
- an NPC caused damage
- a neutral building caused damage (e.g. turret or gate field)
- a building of a player who already left the game caused damage
- a projectile caused damage but the player left before the projectile reached its target/exploded
weapon can be a weapon type ID or a special source ID (see images below).
Often source will be 0 if the damage was caused by a special source.
In many cases you will then get the ID of the attacking object with the object parameter.
hpdmg is the value which will be subtracted from the victim's health and apdmg is the value which will be subtracted from its armor.
rawdmg is the actual raw damage which was caused by the attack without taking the armor of the victim into account.
CS2D Damage calculation (in this order):
- if a player is a zombie (zombie sv_gamemode only), damage will be reduced based on mp_zombiedmg
- if a player wears a special armor, damage will be reduced by the displayed percentage in the HUD (damage * (100-protection)/100)
- if a player wears kevlar armor (armor value between 1 and 200), health and armor are changed based on mp_kevlar (see mp_kevlar for details)
- if multiple players/things are hit by a single shot, mp_shotweakening can reduce the damage for the second, third etc. player who is hit
You can ignore the hit (the victim won't suffer any damage) by returning 1.
Note that on client side you will always hit effects (e.g. blood) even when returning 1.
Weapon and item type IDs:
Special source IDs:
Return Values
- 0: proceed normally
- 1: ignore this hit (no damage)