GetVehicleHealth in textdraw problem
#1

I have textdraws Ostecenje(Impaired) and i use this script :
Quote:

if(IsPlayerInAnyVehicle(playerid))
{
if(!VoziloJeBicikla(GetVehicleModel(GetPlayerVehic leID(playerid))))
{
new Ostecenje[100];new Float:HP;
GetVehicleHealth(GetPlayerVehicleID(playerid), HP);
format(Ostecenje, sizeof(Ostecenje), "%d", HP*0.0001);
PlayerTextDrawSetString(playerid, Speedo[14][playerid], Ostecenje);
}
}

And i have this results http://www.dodaj.rs/f/D/1q/FbBIhzd/sa-mp-251.png with OstecenjeImpaired i want to be 10% 20% no 115.3111111112312 Please help and sorry because bad English..
Reply
#2

pawn Код:
format(Ostecenje, sizeof(Ostecenje), "%d", floatround (HP / 10));
Reply
#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
#4

Tnx b3nz now work, but and you Slo for try help
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)