Need some help with this formula to calculate kill death ratio
#1

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 ";"
Reply
#2

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
Reply
#3

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")));
Reply
#4

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

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

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


Forum Jump:


Users browsing this thread: 1 Guest(s)