پرش به مطلب اصلی

NPC_GetVehicleHealth

هشدار

This function was added in omp v1.5.8.3079 and will not work in earlier versions!

Description

Gets the health of an NPC's vehicle.

NameDescription
npcidThe ID of the NPC

Returns

Returns the vehicle health as a float value, or 0.0 if the NPC is not in a vehicle.

Examples

public OnPlayerCommandText(playerid, cmdtext[])
{
if (!strcmp(cmdtext, "/checkvehiclehealth", true))
{
new npcid = PlayerNPC[playerid];
if (npcid == INVALID_NPC_ID)
return SendClientMessage(playerid, 0xFF0000FF, "You are not debugging a NPC.");

if (!NPC_IsValid(npcid))
return SendClientMessage(playerid, 0xFF0000FF, "Invalid NPC.");

if (NPC_GetVehicle(npcid) == INVALID_VEHICLE_ID)
return SendClientMessage(playerid, 0xFFFF00FF, "NPC %d is not in any vehicle.", npcid);

new Float:health;
NPC_GetVehicleHealth(npcid, health);

SendClientMessage(playerid, 0x00FF00FF, "NPC %d vehicle health: %.2f", npcid, health);
return 1;
}
return 0;
}

Notes

  • Returns 0.0 if the NPC is not in a vehicle
  • Vehicle health typically ranges from 0.0 to 1000.0
  • Health below 250.0 usually means the vehicle will catch fire

No specific callbacks are triggered by this function.