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|__EDIT_ME__}}
{{FuncDescription|Get the specified player's health.}}


{{FuncSyntax|GetPlayerHealth(player)}}
{{FuncSyntax|GetPlayerHealth(player)}}
{{FuncSyntaxClient|GetPlayerHealth()}}


{{FuncParameters}}
{{FuncParameters}}
{{FuncParam|player|__EDIT_ME__}}
{{FuncParam|player|The player identifier.}}


{{FuncReturnValue|__EDIT_ME__}}
{{FuncReturnValue|Returns the player's health in floating point number.}}


== Example ==
== Example ==
__EDIT_ME__
<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}}
__EDIT_ME__
* [[SetPlayerHealth]]
* [[GetPlayerHealth]]

Latest revision as of 10:06, 19 November 2019

GetPlayerHealth

Type: Function
Context: Server & Client
Introduced: v1.0

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)

See also