How would I add a K/D? -
Hernando - 02.02.2013
So, I have a global variable that stores player stats, and I want to know how I would get a k/d from the kills and deaths? I have tried, and I don't get like the following: 2.39, I would get just the 2, it wouldn't have the .ANYTHING? Please help?
pawn Код:
CURRENT CODE:
new string[128];
new kd = PlayerInfo[playerid][pKills] / PlayerInfo[playerid][pDeaths];
format(string, 128, "|___________________Stats of %s___________________|", GPN(targetid));
SCM(playerid, COLOR_WHITE, string);
format(string, 128, "AdminLevel:[%d] | Money:[%d] | Playing Hours:[%d]", PlayerInfo[targetid][pAdmin],PlayerInfo[targetid][pMoney], PlayerInfo[targetid][pConnectTime]);
SCM(playerid, COLOR_LIGHTGREEN, string);
format(string, 128, "K/D Ratio:[%.2d] | Kills:[%d] | Deaths:[%d] | Kill Streak:[%d]",kd, PlayerInfo[targetid][pKills],PlayerInfo[targetid][pDeaths], KillStreak[targetid]);
SCM(playerid, COLOR_LIGHTGREEN, string);
SCM(playerid, COLOR_WHITE, "_______________________________________________________");
return 1;
Re: How would I add a K/D? -
Lorenc_ - 02.02.2013
1. instead of %.2d, try %.2f
2. new Float: kd = blah blah
Re: How would I add a K/D? -
Hernando - 02.02.2013
Quote:
Originally Posted by Lorenc_
1. instead of %.2d, try %.2f
2. new Float: kd = blah blah
|
Testing now.
Re: How would I add a K/D? -
Hernando - 02.02.2013
I did that, and now it just says like.. It just says the 2.00, it won't go any higher than .00, but, once it gets over a 3.0 kd it goes to 3.00 and you see what this means?
btw, new current code:
pawn Код:
new string[128];
new Float:kd = PlayerInfo[playerid][pKills] / PlayerInfo[playerid][pDeaths];
format(string, 128, "|___________________Stats of %s___________________|", GPN(targetid));
SCM(playerid, COLOR_WHITE, string);
format(string, 128, "AdminLevel:[%d] | Money:[%d] | Playing Hours:[%d]", PlayerInfo[targetid][pAdmin],PlayerInfo[targetid][pMoney], PlayerInfo[targetid][pConnectTime]);
SCM(playerid, COLOR_LIGHTGREEN, string);
format(string, 128, "K/D Ratio:[%.2f] | Kills:[%d] | Deaths:[%d] | Kill Streak:[%d]",kd, PlayerInfo[targetid][pKills],PlayerInfo[targetid][pDeaths], KillStreak[targetid]);
SCM(playerid, COLOR_LIGHTGREEN, string);
SCM(playerid, COLOR_WHITE, "_______________________________________________________");
return 1;
Re: How would I add a K/D? -
Hernando - 02.02.2013
And I know it is possible, because I saw it on another DM server before.
Re: How would I add a K/D? -
Djole1337 - 02.02.2013
use floatdiv();