K/D Ratio
#1

Hey, I'm trying to add a K/D ratio into /stats but for some reason it's not updating the ratio from the default 0.

Код:
CMD:stats(playerid, params[])
{
	new wstring[238];
	pInfo[playerid][pKD] = pInfo[playerid][pKills] /= pInfo[playerid][pDeaths];
	new kd = pInfo[playerid][pKD];
	new kills = pInfo[playerid][pKills];
	new deaths = pInfo[playerid][pDeaths];

	format(wstring, sizeof(wstring), "Kills:[%d] Deaths:[%d] K/D:[%d]",kills,deaths,kd);
	SendClientMessage(playerid,COLOR_WHITE, wstring);
	return 1;
}
Reply
#2

pawn Код:
new
    Float: kd = floatdiv( pInfo[playerid][pKills], pInfo[playerid][pDeaths] )
;

// --

format(wstring, sizeof(wstring), "Kills:[%d] Deaths:[%d] K/D:[%.2f]",kills,deaths,kd);
It's Float, not an integer.
Reply
#3

Make sure you aren't dividing by zero.
Reply
#4

Your kd ratio is kills divided by deaths so, like Vince says, if you have 0 deaths you are dividing your kills with 0 so it won't work.
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)