GetVehicleHealth in textdraw problem
#3

Try this:
Код:
if(IsPlayerInAnyVehicle(playerid))
{
    if(!VoziloJeBicikla(GetVehicleModel(GetPlayerVehic leID(playerid))))
    {
        new Ostecenje[100];new Float:HP;
        GetVehicleHealth(GetPlayerVehicleID(playerid), HP);
        format(Ostecenje, sizeof(Ostecenje), "%.0f", HP/1000.0);
        PlayerTextDrawSetString(playerid, Speedo[14][playerid], Ostecenje);
    }
}
GetVehicleHealth returns a number from 0 to 1000 as a float. To get it as a percentage, so between 0 and 100, you would need to divide it by 10.
You were also displaying it as an integer (%d), when it should be a float (%f). In the code above, I used %.0f to hide the decimal places using the .0
Hope this helped!
Reply


Messages In This Thread
GetVehicleHealth in textdraw problem - by Vaki - 17.06.2015, 19:38
Re: GetVehicleHealth in textdraw problem - by b3nz - 17.06.2015, 19:46
Re: GetVehicleHealth in textdraw problem - by SloProKiller - 17.06.2015, 19:50
Re: GetVehicleHealth in textdraw problem - by Vaki - 17.06.2015, 19:52

Forum Jump:


Users browsing this thread: 1 Guest(s)