Scripting/Squirrel/Functions/Vehicles/Health
From VC-MP Wiki
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
- CreateVehicle
- FindVehicle
- GetVehicleCount
- GetVehicleModelFromName
- GetVehicleNameFromModel
- Vehicle.Alarm
- Vehicle.Angle
- Vehicle.Colour1
- Vehicle.Colour2
- Vehicle.Driver
- Vehicle.Fix
- Vehicle.Health
- Vehicle.ID
- Vehicle.IsLocked
- Vehicle.KillEngine
- Vehicle.Lights
- Vehicle.Model
- Vehicle.Pos
- Vehicle.Respawn
- Vehicle.RespawnAs
- Vehicle.RespawnAt
- Vehicle.SetFlatTyres
- Vehicle.SpawnPos
- Vehicle.SpawnAngle
- Vehicle.Velocity
- Vehicle.Remove
