09.07.2014, 07:51
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?
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.
}