Calculating problem
#1

Hi guys...
I want to show the damage/health of a car in % and that's what I have:
pawn Код:
new Float:vhp, vhp2;
GetVehicleHealth(v, vhp);
vhp = (100 / 1000 * vhp);
vhp2 = floatround(vhp, floatround_round);
when I format it into a text it always shows "0%" however it should show 100%
Reply
#2

show us more code.
Where you use it to show the damage.
Reply
#3

pawn Код:
new string[100];
format(string, sizeof(string), "%d%", vhp2);
SendClientMessage(playerid, GREY, string);
(I know that I don't need [100] for this code, however string is used later, again with a longer text..)
Reply
#4

You divide with 10. health/10 = % of health since 1000 is max.
Reply
#5

Your calculation is wrong.
Код:
vhp = (vhp / 10);
Mike Garber was faster ;d
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)