03.04.2013, 12:48
Hi!
I have this script:
It's supposed to remove fuel depending on the speed of a player, all the results are correct, it removes the fuel correctly but when I convert it to a percentage it messes up.
I have no idea what could be going wrong because when I look at the printf that I created there, it gives me this:
Currently Going 50 | Fuel 399980 | Fuel Percentage 0 | 399980/400000*1000
Which when I enter in to my calculator, gives me the correct answer of 99.995
I've tried changing it to a float variable but that didn't help, did I possibly do something wrong?
Kind Regards
Matthew
P.S. s2[playerid] is the Speed at which the player is going by the way.
I have this script:
pawn Код:
format(fuelStr[GetPlayerVehicleID(playerid)],256,"Fuel: %i%%", vehicleFuel[GetPlayerVehicleID(playerid)]/400000*100); // This Format Our Text Into What We See
TextDrawSetString(fdisplay[playerid], fuelStr[GetPlayerVehicleID(playerid)]); // This Changes The Value Of Our Textdraw To What We Formatted
if(s2[playerid] != 0) {
vehicleFuel[GetPlayerVehicleID(playerid)] = (vehicleFuel[GetPlayerVehicleID(playerid)]-(s2[playerid]*5/18));
}
printf("Currently going %d | Fuel %d Left | Fuel Percentage: %d | %d/400000*100", s2[playerid], vehicleFuel[GetPlayerVehicleID(playerid)], vehicleFuel[GetPlayerVehicleID(playerid)]/400000*100, vehicleFuel[GetPlayerVehicleID(playerid)]);
pawn Код:
vehicleFuel[GetPlayerVehicleID(playerid)]/400000*100
Currently Going 50 | Fuel 399980 | Fuel Percentage 0 | 399980/400000*1000
Which when I enter in to my calculator, gives me the correct answer of 99.995
I've tried changing it to a float variable but that didn't help, did I possibly do something wrong?
Kind Regards
Matthew
P.S. s2[playerid] is the Speed at which the player is going by the way.