GetPlayerHealth: Difference between revisions
From Onset Developer Wiki
No edit summary |
No edit summary |
||
Line 1: | Line 1: | ||
{{Info|Function|Server & Client|1.0}} | {{Info|Function|Server & Client|1.0}} | ||
{{FuncDescription| | {{FuncDescription|Get the specified player's health.}} | ||
{{FuncSyntax|GetPlayerHealth(player)}} | {{FuncSyntax|GetPlayerHealth(player)}} | ||
{{FuncSyntaxClient|GetPlayerHealth()}} | |||
{{FuncParameters}} | {{FuncParameters}} | ||
{{FuncParam|player| | {{FuncParam|player|The player identifier.}} | ||
{{FuncReturnValue| | {{FuncReturnValue|Returns the player's health in floating point number.}} | ||
== Example == | == Example == | ||
<syntaxhighlight lang="Lua> | |||
AddCommand("heal", function(playerid) | |||
if GetPlayerHealth(playerid) < 30.0 then | |||
SetPlayerHealth(playerid, 100.0) | |||
else | |||
AddPlayerChat(playerid, "You have enough health.") | |||
end | |||
end) | |||
</syntaxhighlight> | |||
{{RelatedFunctions}} | {{RelatedFunctions}} | ||
* [[SetPlayerHealth]] | |||
* [[GetPlayerHealth]] |
Latest revision as of 10:06, 19 November 2019
Description
Get the specified player's health.
Syntax
GetPlayerHealth(player)
Client Syntax
GetPlayerHealth()
Parameters
- player
The player identifier.
Return Value
- Returns the player's health in floating point number.
Example
AddCommand("heal", function(playerid)
if GetPlayerHealth(playerid) < 30.0 then
SetPlayerHealth(playerid, 100.0)
else
AddPlayerChat(playerid, "You have enough health.")
end
end)