SetPlayerHealth: Difference between revisions

From Multi Theft Auto: Wiki
Jump to navigation Jump to search
mNo edit summary
No edit summary
 
(6 intermediate revisions by 4 users not shown)
Line 1: Line 1:
__NOTOC__
__NOTOC__
This function allows you to set a player's health.
{{Server client function}}
 
{{Deprecated|setElementHealth|}}
==Syntax==
<syntaxhighlight lang="lua">
bool setPlayerHealth ( player thePlayer, float playerHealth )
</syntaxhighlight>
 
===Required Arguments===
*'''thePlayer''': The [[player]] whose health you want to set.
*'''playerHealth''': The value you want to set the health to. Valid values are from 0 (dead) to 100 (full health).
 
===Returns===
Returns ''true'' if the player's health was set succesfully. Returns ''false'' if the player argument is invalid, or the health argument is out of range.
 
==Example==
This example finds "player" and when "slap" is entered, their health is decreased
<syntaxhighlight lang="lua">
function slap ( player, command ) --calls the function
setPlayerHealth ( player, getPlayerHealth(player) - 20 ) --sets the player health
end
addCommandHandler ( "slap", slap )
</syntaxhighlight>
 
==See Also==
{{Player functions}}

Latest revision as of 22:24, 1 July 2019

Emblem-important.png This function is deprecated. This means that its use is discouraged and that it might not exist in future versions.

Please use setElementHealth instead.