OnNPCDeath: Difference between revisions

From Onset Developer Wiki
Created page with "{{Info|Event|Server|1.0}} {{FuncDescription|__EDIT_ME__}} {{FuncSyntax|OnNPCDeath}} {{FuncParameters}} == Example == __EDIT_ME__ {{RelatedFunctions}} {{ServerEvents}}"
 
28days (talk | contribs)
No edit summary
 
(2 intermediate revisions by 2 users not shown)
Line 1: Line 1:
{{Info|Event|Server|1.0}}
{{Info|Event|Server|1.0}}


{{FuncDescription|__EDIT_ME__}}
{{FuncDescription|Event thats called when a NPC dies.}}


{{FuncSyntax|OnNPCDeath}}
{{FuncSyntax|OnNPCDeath(npc, player)}}


{{FuncParameters}}
{{FuncParameters}}
{{FuncParam|npc|The npc that died.}}
{{FuncParam|player|Instigator, 0 if not killed by a player.}}
== Example ==
== Example ==
__EDIT_ME__
<syntaxhighlight lang="Lua">
AddEvent("OnNPCDeath", function(npcId, playerId)
    if playerId != 0 then
        -- If the death is inspected by a real player
    end
end)
</syntaxhighlight>


{{RelatedFunctions}}
{{RelatedFunctions}}
{{ServerEvents}}
{{Template:NPCEvents}}

Latest revision as of 07:09, 13 December 2019

OnNPCDeath

Type: Event
Context: Server
Introduced: v1.0

Description

Event thats called when a NPC dies.

Syntax

OnNPCDeath(npc, player)

Parameters

  • npc
    The npc that died.
  • player
    Instigator, 0 if not killed by a player.

Example

AddEvent("OnNPCDeath", function(npcId, playerId)
    if playerId != 0 then
        -- If the death is inspected by a real player
    end
end)

See also