SA-MP Forums Archive
K/d - 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: K/d (/showthread.php?tid=549446)



K/d - LeXuZ - 06.12.2014

Hello, I was wondering how would I make a kill death ratio(k/d) for my stats, if you know how please show me, thank you!


Re: K/d - Kaperstone - 06.12.2014

kill/deaths
(divide)
literally


Re: K/d - Schneider - 06.12.2014

pawn Код:
new totalkills, totaldeaths, Float:kdratio;
@OnPlayerDeath update the kills and deaths accordingly:
pawn Код:
totalkills++; totaldeaths++;
To calculate the ratio, just divide the kills with the deaths.
pawn Код:
kdratio = floatdiv(totalkills, totaldeaths);



Re: K/d - Kaperstone - 06.12.2014

@Schneider, You do know that this is the same as using ' / ' (refering to floatdiv)


Re: K/d - Schneider - 06.12.2014

@Kaperstone: I know I'm not the best scripter out here, but I tested both ways but using '/' didn't work.

I've put this under main()
pawn Код:
new kills = 50, deaths = 100, Float:kdratio1, Float:kdratio2;
kdratio1 = kills/deaths;
kdratio2 = floatdiv(kills, deaths);
printf("KD1: %.2f", kdratio1);
printf("KD2: %.2f", kdratio2);
Result:
KD1: 0.00
KD2: 0.50

So floatdiv is working, but '/' does not.