GetNPCHealth: Difference between revisions
From Onset Developer Wiki
Created page with "{{Info|Function|Server|1.0}} {{FuncDescription|__EDIT_ME__}} {{FuncSyntax|GetNPCHealth(npc)}} {{FuncParameters}} {{FuncParam|npc|__EDIT_ME__}} {{FuncReturnValue|__EDIT_ME_..." |
No edit summary |
||
(3 intermediate revisions by 2 users not shown) | |||
Line 1: | Line 1: | ||
{{Info|Function|Server|1.0}} | {{Info|Function|Server|1.0}} | ||
{{FuncDescription| | {{FuncDescription|Returns NPC's health by its identifier.}} | ||
{{FuncSyntax|GetNPCHealth(npc)}} | {{FuncSyntax|GetNPCHealth(npc)}} | ||
{{FuncParameters}} | {{FuncParameters}} | ||
{{FuncParam|npc| | {{FuncParam|npc|NPC you want to get health of}} | ||
{{FuncReturnValue| | {{FuncReturnValue|The NPC health as a floating point number.}} | ||
== Example == | == Example == | ||
<syntaxhighlight lang="Lua"> | |||
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) | |||
</syntaxhighlight> | |||
{{RelatedFunctions}} | {{RelatedFunctions}} | ||
*[[SetNPCRagdoll]] | |||
*[[SetNPCDimension]] | |||
*[[GetNPCDimension]] | |||
*[[SetNPCPropertyValue]] | |||
*[[GetNPCPropertyValue]] | |||
*[[CreateNPC]] | |||
*[[DestroyNPC]] | |||
*[[IsValidNPC]] | |||
*[[GetAllNPC]] | |||
*[[GetNPCCount]] | |||
*[[IsNPCStreamedIn]] | |||
*[[SetNPCLocation]] | |||
*[[GetNPCLocation]] | |||
*[[SetNPCHealth]] | |||
*[[GetNPCHealth]] | |||
*[[SetNPCAnimation]] | |||
*[[SetNPCHeading]] | |||
*[[GetNPCHeading]] | |||
*[[SetNPCTargetLocation]] | |||
*[[SetNPCFollowPlayer]] | |||
*[[SetNPCFollowVehicle]] |
Latest revision as of 14:50, 23 December 2020
Description
Returns NPC's health by its identifier.
Syntax
GetNPCHealth(npc)
Parameters
- npc
NPC you want to get health of
Return Value
- The NPC health as a floating point number.
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
- SetNPCRagdoll
- SetNPCDimension
- GetNPCDimension
- SetNPCPropertyValue
- GetNPCPropertyValue
- CreateNPC
- DestroyNPC
- IsValidNPC
- GetAllNPC
- GetNPCCount
- IsNPCStreamedIn
- SetNPCLocation
- GetNPCLocation
- SetNPCHealth
- GetNPCHealth
- SetNPCAnimation
- SetNPCHeading
- GetNPCHeading
- SetNPCTargetLocation
- SetNPCFollowPlayer
- SetNPCFollowVehicle