GetVehicleHealth in textdraw problem - Printable Version
+- SA-MP Forums Archive (
https://sampforum.blast.hk)
+-- Forum: SA-MP Scripting and Plugins (
https://sampforum.blast.hk/forumdisplay.php?fid=8)
+--- Forum: Scripting Help (
https://sampforum.blast.hk/forumdisplay.php?fid=12)
+--- Thread: GetVehicleHealth in textdraw problem (
/showthread.php?tid=578242)
GetVehicleHealth in textdraw problem -
Vaki - 17.06.2015
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 Ostecenje
Impaired
i want to be 10% 20% no 115.3111111112312 Please help and sorry because bad English..
Re: GetVehicleHealth in textdraw problem -
b3nz - 17.06.2015
pawn Код:
format(Ostecenje, sizeof(Ostecenje), "%d", floatround (HP / 10));
Re: GetVehicleHealth in textdraw problem -
SloProKiller - 17.06.2015
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!
Re: GetVehicleHealth in textdraw problem -
Vaki - 17.06.2015
Tnx b3nz now work, but and you Slo for try help