Vehicle Health
#1

hello i want to make vehicle health only for one vehicle with 3DTextLabelText and i have do it, but health say all time 0 here is my code
pawn Код:
public OnGameModeInit()
{
    SetTimer("rhinoHP", 250, true);
return 1;
}
forward rhinoHP(playerid);
public rhinoHP(playerid)
{
new rstr[30];
new Float:health;
format(rstr, sizeof(rstr), "health: %.2f", GetVehicleHealth(432, health));
Update3DTextLabelText(vehicle3Dtext[ Rhino1 ], 0xFFFFFFAA, rstr);
}
Reply
#2

https://sampwiki.blast.hk/wiki/SetTimer
https://sampwiki.blast.hk/wiki/SetTimerEx

First of all, learn how to use timers with or without parameters. SetTimer does not have parameters, even though you used playerid for no reason. You also try to return the health directly but that way, it only returns 1 on success and 0 on failure (invalid vehicle ID). SA-MP Wiki also says: The vehicle's health is stored in the referenced variable, not in the return value - in your case health.
Reply
#3

PHP код:
public OnVehicleSpawn(vehicleid)
{
    
SetTimerEx("rhinoHP"250true"i"vehicleid);
    return 
1;
}
forward rhinoHP(vehicleid);
public 
rhinoHP(vehicleid)
{
      new 
rstr[30], Float:health;
      if(
GetVehicleModel(vehicleid) == 432)
      {
          
format(rstrsizeof(rstr), "health: %.2f"GetVehicleHealth(vehicleidhealth));
          
Update3DTextLabelText(vehicle3DtextRhino1 ], 0xFFFFFFAArstr);
    }
    return 
1;

Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)