Entity::setHealth: Difference between revisions

From RAGE Multiplayer Wiki
(yay)
 
 
(One intermediate revision by one other user not shown)
Line 1: Line 1:
health >= 0
Sets entity health to a specified value.
 
*'''Player''': For some reason health is calculated relying on 100 + actual player health. Setting value to 100 will result in player having 0 health but not dead, values <100 will kill the player.
*'''Vehicle''': Setting health of a vehicle doesn't seem to have any technical results, vehicle will not be destroyed at 0 mark even after any damage.
 
==Syntax==
==Syntax==
<syntaxhighlight lang="javascript">entity.setHealth(health);</syntaxhighlight>
<syntaxhighlight lang="javascript">entity.setHealth(health);</syntaxhighlight>
Line 8: Line 12:
==Example==
==Example==
<syntaxhighlight lang="javascript">
<syntaxhighlight lang="javascript">
// todo
mp.players.local.setHealth(150); // Setting player health to 50
mp.players.local.setHealth(200); // Setting player health to 100
</syntaxhighlight>
</syntaxhighlight>
==See also==
==See also==
{{Entity_function_c}}
{{Entity_definition_c}}
[[Category:Clientside API]]
[[Category:Clientside API]]
[[Category:TODO: Example]]
[[Category: Example]]

Latest revision as of 18:00, 1 May 2024

Sets entity health to a specified value.

  • Player: For some reason health is calculated relying on 100 + actual player health. Setting value to 100 will result in player having 0 health but not dead, values <100 will kill the player.
  • Vehicle: Setting health of a vehicle doesn't seem to have any technical results, vehicle will not be destroyed at 0 mark even after any damage.

Syntax

entity.setHealth(health);

Required Arguments

  • health: int

Return value

  • Undefined

Example

mp.players.local.setHealth(150); // Setting player health to 50
mp.players.local.setHealth(200); // Setting player health to 100

See also