Scripting/Squirrel/Events/Player/onPlayerHealthChange

From VC-MP Wiki

Jump to: navigation, search

This is called when player's health amount changes.

Syntax

function onPlayerHealthChange( player, oldHealth, newHealth )

Parameters

  • player - The pointer of the player
  • oldHealth - The amount of health player had before the change
  • newHealth - The current health amount

Example

This will tell the player if they got hurt.

function onPlayerHealthChange( player, oldhp, newhp )
{
     if ( oldhp > newhp ) MessagePlayer( "You just lost " + ( oldhp - newhp ) + " health.", player );
}

Notes

The function MessagePlayer was used in in this example. More info about it in the corresponding page.

Related Events

Personal tools
squirrel scripting