SA-MP Forums Archive
Need some help with this formula to calculate kill death ratio - 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: Need some help with this formula to calculate kill death ratio (/showthread.php?tid=69441)



Need some help with this formula to calculate kill death ratio - Celson - 18.03.2009

I'm trying to create this formula that will calcuate you Killseaths. But I suck at placing the + - / *

So can anyone fix this line up?

Код:
dUserSetINT(PlayerName(killerid)).("kdratio", (dUserINT(PlayerName(killerid)).("kills")/(dUserINT(PlayerName(killerid)).("deaths")));
error 001: expected token: ",", but found ";"


Re: Need some help with this formula to calculate kill death ratio - [RP]Rav - 18.03.2009

pawn Код:
new Float: ratio;
if (kills[killerid] > 0 && deaths[killerid] > 0)
  ratio = kills[killerid] / deaths[killerid];
else
  ratio = 0;
then use the variable to save it, it looks much cleaner


Re: Need some help with this formula to calculate kill death ratio - Celson - 18.03.2009

Quote:
Originally Posted by Rav
pawn Код:
new Float: ratio;
if (kills[killerid] > 0 && deaths[killerid] > 0)
  ratio = kills[killerid] / deaths[killerid];
else
  ratio = 0;
then use the variable to save it, it looks much cleaner
Ehh no thanks, it's only one line to calculate the ratio. Can anyone fix that up for me?

I just need this part fixed up

Код:
(dUserINT(PlayerName(killerid)).("kills")/(dUserINT(PlayerName(killerid)).("deaths")));



Re: Need some help with this formula to calculate kill death ratio - LarzI - 18.03.2009

pawn Код:
dUserSetINT(PlayerName(killerid)).("kdration", dUserINT(PlayerName(killerid)).("kills")/dUserINT(PlayerName(killerid)).("deaths"));



Re: Need some help with this formula to calculate kill death ratio - [RP]Rav - 18.03.2009

remember that if you keep it that line the script may crash if it tries to divide by 0...


Re: Need some help with this formula to calculate kill death ratio - MenaceX^ - 18.03.2009

pawn Код:
*1.0/ // This will create the ratio. (It's a float. Use %d.)