Garry's Mod Wiki



Called when an entity dies.

This is not called when a player dies using Player:KillSilent.


number entindex_inflictor
The EntIndex of the inflictor..
number damagebits
Damage type(s), a combination of DMG enum.



This is a basic template with the purpose of including all arguments / table variables to make it easily known which values can be accessed.

gameevent.Listen( "entity_killed" ) hook.Add( "entity_killed", "entity_killed_example", function( data ) local inflictor_index = data.entindex_inflictor // Same as Weapon:EntIndex() / weapon used to kill victim local attacker_index = data.entindex_attacker // Same as Player/Entity:EntIndex() / person or entity who did the damage local damagebits = data.damagebits // DAMAGE_TYPE - use BIT operations to decipher damage types... local victim_index = data.entindex_killed // Same as Victim:EntIndex() / the entity / player victim // Called when a Player or Entity is killed end )