GetPlayerHealth: Difference between revisions
From Onset Developer Wiki
Created page with "{{Info|Function|Server|1.0}} {{FuncDescription|__EDIT_ME__}} {{FuncSyntax|GetPlayerHealth(player)}} {{FuncParameters}} {{FuncParam|player|__EDIT_ME__}} {{FuncReturnValue|_..." |
No edit summary |
||
(One intermediate revision by one other user not shown) | |||
Line 1: | Line 1: | ||
{{Info|Function|Server|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)