Problem with percentage calculation - 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)
+--- Thread: Problem with percentage calculation (
/showthread.php?tid=532492)
Problem with percentage calculation -
Derexi - 18.08.2014
I'm trying to present a percentage in a dialog. It's the percentage of kills from your total kills and deaths.
I did:
Код:
new total, Float:total2;
total = pData[playerid][Kills] + pData[playerid][Deaths];
total2 = pData[playerid][Kills] / total;
format(tmp, 120, "{FFFFFF}You've killed {8CFF00}%d {ffffff}times and died {8CFF00}%d {FFFFFF}times, giving you a kill rate of %d%%,\n", pData[playerid][Kills], pData[playerid][Deaths], floatround(total2));
strcat(str, tmp);
But in the dialog is just shows as 0%, even though my kills and deaths are set as 234 and 76.
Re: Problem with percentage calculation -
iFarbod - 18.08.2014
Use float()