Scripting/Squirrel/Functions/Vehicles/Health

From VC-MP Wiki

Jump to: navigation, search

This instance variable returns or sets the health of a vehicle. Note: Setting vehicle health is not working properly in VC-MP 0.3z due to a bug in the client.

Syntax

float vehicle.Health

vehicle.Health = float newHealth

Example: Returning

This command gives the health of the vehicle the player is in when they type '/c carhp'.

function onPlayerCommand( player, cmd, text )
{
     if ( cmd == "carhp" )
     {
          local veh = player.Vehicle;
          
          if ( !veh ) MessagePlayer( "Error: You are on foot.", player );
          else MessagePlayer( "Vehicle health: " + ( veh.Health / 10 ), player );
     }
}

Notes

The functions MessagePlayer, player.Vehicle and call onPlayerCommand were used in in this example. More info about them in corresponding pages.

Related Functions

Personal tools
squirrel scripting