Garry's Mod Wiki

Garry's Mod Wiki

  GM:OnNPCKilled( NPC npc, Entity attacker, Entity inflictor )

Description

Called whenever an NPC is killed.

Arguments

1 NPC npc
The killed NPC
2 Entity attacker
The NPCs attacker, the entity that gets the kill credit, for example a player or an NPC.
3 Entity inflictor
Death inflictor. The entity that did the killing. Not necessarily a weapon.

Example

Spawns an explosion effect on an NPC when they die.

hook.Add( "OnNPCKilled", "ExplosionEffectOnNPCDeath", function( npc, attacker, inflictor ) local effectData = EffectData() effectData:SetOrigin( npc:GetPos() ) util.Effect( "Explosion", effectData ) end)

This site is a community mirror of the official Garry's Mod wiki.. This site is not maintained by Facepunch Studios.

Page content is automatically updated four times a day. Edits and history are not available.

Last Parsed: Loading...