Calculating problem - 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)
+---- Forum: Help Archive (
https://sampforum.blast.hk/forumdisplay.php?fid=89)
+---- Thread: Calculating problem (
/showthread.php?tid=244261)
Calculating problem -
Sascha - 26.03.2011
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%
Re: Calculating problem -
armyoftwo - 26.03.2011
show us more code.
Where you use it to show the damage.
Re: Calculating problem -
Sascha - 26.03.2011
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..)
Re: Calculating problem -
Mike Garber - 26.03.2011
You divide with 10. health/10 = % of health since 1000 is max.
Re: Calculating problem -
armyoftwo - 26.03.2011
Your calculation is wrong.
Mike Garber was faster ;d