Need help with vehicle damage percentage
#1

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.
        }
Reply
#2

pawn Код:
new Float: health;
GetVehicleHealth(GetPlayerVehicleID(playerid), health);
format(String, sizeof (String), "Time: %d seconds, Damage: %.0f.", be_sec, 1000.0 - health);
Reply
#3

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
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)