GetNPCHealth: Difference between revisions
From Onset Developer Wiki
No edit summary |
No edit summary |
||
Line 1: | Line 1: | ||
{{Info|Function|Server|1.0}} | {{Info|Function|Server|1.0}} | ||
{{FuncDescription| | {{FuncDescription|Returns NPC's health by its ID}} | ||
{{FuncSyntax|GetNPCHealth(npc)}} | {{FuncSyntax|GetNPCHealth(npc)}} | ||
Line 13: | Line 13: | ||
<syntaxhighlight lang="Lua"> | <syntaxhighlight lang="Lua"> | ||
function checkHealth(player, npc) | function checkHealth(player, npc) | ||
AddPlayerChat(player, 'NPC has: ' .. GetNPCHealth(npc) .. ' health') | if IsValidNPC(tonumber(npc) then | ||
AddPlayerChat(player, 'NPC has: ' .. GetNPCHealth(tonumber(npc)) .. ' health') | |||
else | |||
AddPlayerChat(player, 'This NPC doesn\'t exist!') | |||
end | |||
end | end | ||
AddCommand('npchealth', checkHealth) | AddCommand('npchealth', checkHealth) |
Revision as of 19:56, 13 November 2019
Description
Returns NPC's health by its ID
Syntax
GetNPCHealth(npc)
Parameters
- npc
NPC you want to get health of
Return Value
- NPC Health
Example
function checkHealth(player, npc)
if IsValidNPC(tonumber(npc) then
AddPlayerChat(player, 'NPC has: ' .. GetNPCHealth(tonumber(npc)) .. ' health')
else
AddPlayerChat(player, 'This NPC doesn\'t exist!')
end
end
AddCommand('npchealth', checkHealth)
See also
__EDIT_ME__