SetPlayerHealth: Difference between revisions

From Multi Theft Auto: Wiki
Jump to navigation Jump to search
No edit summary
No edit summary
Line 1: Line 1:
__NOTOC__
__NOTOC__
==Description==
This function allows you to set a player's health directly. It may return false if the player object is invalid, or the health argument is out of range.
This function allows you to set a player's health directly. It may return false if the player object is invalid, or the health argument is out of range.


==Syntax==
==Syntax==
 
<syntaxhighlight lang="lua">bool setPlayerHealth ( player thePlayer, float playerHealth )</syntaxhighlight>
bool [[setPlayerHealth]] ( [[player]] player, float health )


===Required Arguments===
===Required Arguments===
*'''player''': The [[player]] whose health you want to set
*'''player''': The [[player]] whose health you want to set
*'''health''': The value you want to set the health to. Valid values are from 0 to 100
*'''health''': The value you want to set the health to. Valid values are from 0 to 100
===Returns===
Returns false if the player object is invalid, or the health argument is out of range.


==Example==
==Example==
  if ( [[setPlayerHealth]] ( [[findPlayer]] ( "Someguy" ), 1 ) ) then
  <syntaxhighlight lang="lua">if ( setPlayerHealth ( findPlayer ( "Someguy" ), 1 ) ) then
   [[serverChat]] ( "Someguy's life expectancy just got a lot less expected." )
   outputChatBox ( "Someguy's life expectancy just got a lot less expected.", player )
  end
  end</syntaxhighlight>

Revision as of 17:12, 18 May 2006

This function allows you to set a player's health directly. It may return false if the player object is invalid, or the health argument is out of range.

Syntax

bool setPlayerHealth ( player thePlayer, float playerHealth )

Required Arguments

  • player: The player whose health you want to set
  • health: The value you want to set the health to. Valid values are from 0 to 100

Returns

Returns false if the player object is invalid, or the health argument is out of range.

Example

if ( setPlayerHealth ( findPlayer ( "Someguy" ), 1 ) ) then
   outputChatBox ( "Someguy's life expectancy just got a lot less expected.", player )
 end