Commands/Lua

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

CS2D Command CS2D Console Commands

Lua Hook Lua Hooks

Category: all (70)

Lua Hook 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.
Note that the source 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 victims 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.

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:
items

Special source IDs:
killids

Note: When the health of the victim reaches 0, the die hook (and optionally the kill hook) will be executed directly afterwards!

Return Values

  • 0: proceed normally
  • 1: ignore this hit (no damage)

Lua Command Lua Commands