Revision Difference
GM:OnNPCKilled#546630
<function name="OnNPCKilled" parent="GM" type="hook">
<ishook>yes</ishook>
<description>Called whenever an NPC is killed.</description>
<realm>Server</realm>
<predicted>No</predicted>
<hidepredictionwarning>No</hidepredictionwarning>
<args>
<arg name="npc" type="NPC">The killed NPC</arg>
<arg name="attacker" type="Entity">The NPCs attacker, the entity that gets the kill credit, for example a player or an NPC.</arg>
<arg name="inflictor" type="Entity">Death inflictor. The entity that did the killing. Not necessarily a weapon.</arg>
</args>
</function>⤶
⤶
⤶
</function>⤶
⤶
<example>⤶
<description>Spawns an explosion effect on an NPC when they die.</description>⤶
<code> ⤶
hook.Add("OnNPCKilled", "ExplosionEffectOnNPCDeath", function(npc, attacker, inflictor)⤶
local effectData = EffectData()⤶
effectData:SetOrigin(npc:GetPos())⤶
util.Effect("Explosion", effectData)⤶
end)⤶
</code>⤶
</example>⤶