OnNPCDamage: Difference between revisions

From Onset Developer Wiki
Created page with "{{Info|Event|Server|1.0}} {{FuncDescription|__EDIT_ME__}} {{FuncSyntax|OnNPCDamage}} {{FuncParameters}} == Example == __EDIT_ME__ {{RelatedFunctions}} {{ServerEvents}}"
 
28days (talk | contribs)
No edit summary
 
(One intermediate revision by the same user 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 is damaged.}}


{{FuncSyntax|OnNPCDamage}}
{{FuncSyntax|OnNPCDamage(npc, damagetype, amount)}}


{{FuncParameters}}
{{FuncParameters}}
{{FuncParam|npc|The NPC who is being damaged.}}
{{FuncParam|damagetype|[[DamageType|Type]] of damage applied.}}
{{FuncParam|amount|Amount of damage applied.}}
== Example ==
== Example ==
__EDIT_ME__
<syntaxhighlight lang="Lua">
function OnNPCDamage(npc, damagetype, amount)
local DamageName = {
"Weapon",
"Explosion",
"Fire",
"Fall",
"Vehicle Collision"
}
 
print(npc.." took "..amount.." damage of type "..DamageName[damagetype])
end
AddEvent("OnNPCDamage", OnNPCDamage)
</syntaxhighlight>


{{RelatedFunctions}}
{{RelatedFunctions}}
{{ServerEvents}}
{{Template:NPCFunctions}}

Latest revision as of 20:48, 16 December 2019

OnNPCDamage

Type: Event
Context: Server
Introduced: v1.0

Description

Event thats called when a NPC is damaged.

Syntax

OnNPCDamage(npc, damagetype, amount)

Parameters

  • npc
    The NPC who is being damaged.
  • damagetype
    Type of damage applied.
  • amount
    Amount of damage applied.

Example

function OnNPCDamage(npc, damagetype, amount)
	local DamageName = {
		"Weapon",
		"Explosion",
		"Fire",
		"Fall",
		"Vehicle Collision"
	}

	print(npc.." took "..amount.." damage of type "..DamageName[damagetype])
end
AddEvent("OnNPCDamage", OnNPCDamage)

See also