GetVehicleHealth

From SA-MP Wiki

(Difference between revisions)
Jump to: navigation, search
Revision as of 20:04, 18 January 2014
Smithy (Talk | contribs)

← Previous diff
Revision as of 22:42, 31 January 2014
Connor Mead (Talk | contribs)

Next diff →
Line 36: Line 36:
[[de:GetVehicleHealth]] [[de:GetVehicleHealth]]
 +[[fr:GetVehicleHealth]]

Revision as of 22:42, 31 January 2014



Description:

Get the health of a vehicle.


Parameters:
(vehicleid, &Float:health)
vehicleidThe ID of the vehicle to get the health of.
&Float:healthA float varaible in which to store the vehicle's health, passed by reference


Return Values:

  • 1 - success
  • 0 - failure (invalid vehicle ID).
  • The vehicle's health is stored in the referenced variable, not in the return value.


Image:32px-Ambox_warning_orange.png

Note

Full vehicle health is 1000. For more information on health values, see here.


Tip

Image:Light_bulb_icon.png

A vehicle catches on fire when its health is below 250. It will explode a few seconds later.


if(strcmp(cmdtext, "/repair", true) == 0)
{
    new Float:health;
    new veh = GetPlayerVehicleID(playerid);
    GetVehicleHealth(veh, health);
    if(health > 500) return SendClientMessage(playerid, COLOR_RED, "Vehicle doesn't need repairing!");
    SetVehicleHealth(veh, 1000);
    SendClientMessage(playerid, COLOR_GREEN, "Vehicle repaired!");
}

Related Functions

The following functions may be useful, as they are related to this function in one way or another.

In other languages