Garry's Mod Wiki

entity_killed

Description

Called when an entity dies.

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

Parameters

number entindex_inflictor
The EntIndex of the inflictor..
number entindex_attacker
The EntIndex of the attacker.
number damagebits
Damage type(s), a combination of Enums/DMG.
number entindex_killed
The EntIndex of the victim.

Examples

Example

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 )