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|Returns NPC's health by its ID}}
{{FuncDescription|Returns NPC's health by its identifier.}}


{{FuncSyntax|GetNPCHealth(npc)}}
{{FuncSyntax|GetNPCHealth(npc)}}
Line 8: Line 8:
{{FuncParam|npc|NPC you want to get health of}}
{{FuncParam|npc|NPC you want to get health of}}


{{FuncReturnValue|NPC Health}}
{{FuncReturnValue|The NPC health as a floating point number.}}


== Example ==
== Example ==

Latest revision as of 14:50, 23 December 2020

GetNPCHealth

Type: Function
Context: Server
Introduced: v1.0

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