Need help with vehicle damage percentage - 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: Need help with vehicle damage percentage (
/showthread.php?tid=524915)
Need help with vehicle damage percentage -
IceBilizard - 09.07.2014
guys i have a system on my driving school test function when you finish the test without damage it will show you a message with time seconds and vehicle damage so i create this code if vehicle health will be 1000 it will show you damage 0 but if health decrease to 999 then it will show 99 or 98 i want if vehicle health decrease to 999 or 998 then show like
on 999
Time: 105 seconds, Damage: 1
on 998
Time 105 seconds, Damage: 2
here is my code so please tell me its possible or not? if possible then how to do this?
pawn Код:
new Float:health;
new veh = GetPlayerVehicleID(playerid);
GetVehicleHealth(veh, health);
new Float:percentage = (((health - 250.0) / (1000.0 - 250.0)) * 100.0);
if(percentage > 99)
{
format(String, sizeof(String), "Time: %d seconds, Damage: 0.",be_sec);//You should use .0f to get the correct/perfect percentage.
}
else
{
format(String, sizeof(String), "Time: %d seconds, Damage: %.0f.",be_sec, percentage);//You should use .0f to get the correct/perfect percentage.
}
Re: Need help with vehicle damage percentage -
Konstantinos - 09.07.2014
pawn Код:
new Float: health;
GetVehicleHealth(GetPlayerVehicleID(playerid), health);
format(String, sizeof (String), "Time: %d seconds, Damage: %.0f.", be_sec, 1000.0 - health);
Re: Need help with vehicle damage percentage -
IceBilizard - 09.07.2014
Thanks Konstantinos but a problem
when vehicle's health in 990 it showing 10 on damage i want if vehicle is 990 then show 1 if 890 then 2