How would I add a K/D?
#1

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

1. instead of %.2d, try %.2f
2. new Float: kd = blah blah
Reply
#3

Quote:
Originally Posted by Lorenc_
Посмотреть сообщение
1. instead of %.2d, try %.2f
2. new Float: kd = blah blah
Testing now.
Reply
#4

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;
Reply
#5

And I know it is possible, because I saw it on another DM server before.
Reply
#6

use floatdiv();
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)