Need help with kill/death ratio -
barts - 15.02.2014
PHP код:
format(string, sizeof(string), "Kills: [%d] - Deaths: [%d] - K/D Ratio: [%d] ", PlayerInfo[playerid][Kills], PlayerInfo[playerid][Deaths], PlayerInfo[playerid][Kills]/PlayerInfo[playerid][Deaths]);
This is my /stats cmd
When i test it all works. but K/D ratio always stay at 0, help me please.
Re: Need help with kill/death ratio -
fiki574 - 15.02.2014
pawn Код:
format(string, sizeof(string), "Kills: [%d] - Deaths: [%d] - K/D Ratio: [%f] ", PlayerInfo[playerid][Kills], PlayerInfo[playerid][Deaths], floatround(PlayerInfo[playerid][Kills]/PlayerInfo[playerid][Deaths]));
Re: Need help with kill/death ratio -
MBilal - 15.02.2014
try to use for ratio %f fiki574 is right use that
Re: Need help with kill/death ratio -
Threshold - 15.02.2014
Quote:
Originally Posted by fiki574
pawn Код:
format(string, sizeof(string), "Kills: [%d] - Deaths: [%d] - K/D Ratio: [%f] ", PlayerInfo[playerid][Kills], PlayerInfo[playerid][Deaths], floatround(PlayerInfo[playerid][Kills]/PlayerInfo[playerid][Deaths]));
|
The usage of 'floatround' would convert that back into an integer. So the results might come out a little weird with that code.
pawn Код:
format(string, sizeof(string), "Kills: [%d] - Deaths: [%d] - K/D Ratio: [%.2f] ", PlayerInfo[playerid][Kills], PlayerInfo[playerid][Deaths], (PlayerInfo[playerid][Kills] / PlayerInfo[playerid][Deaths]));
Re: Need help with kill/death ratio -
Konstantinos - 15.02.2014
A run time error about diving with 0 will be caused if deaths are 0. Use this for the ratio:
pawn Код:
floatdiv(PlayerInfo[playerid][Kills], PlayerInfo[playerid][Deaths])
And use placeholder:
instead of:
Re: Need help with kill/death ratio -
barts - 15.02.2014
Konstantinos i didnt understand what you wanna say ?
Re: Need help with kill/death ratio -
Konstantinos - 15.02.2014
pawn Код:
format(string, sizeof(string), "Kills: [%d] - Deaths: [%d] - K/D Ratio: [%.2f] ", PlayerInfo[playerid][Kills], PlayerInfo[playerid][Deaths], floatdiv(PlayerInfo[playerid][Kills], PlayerInfo[playerid][Deaths]));
Re: Need help with kill/death ratio -
ReD_HunTeR - 15.02.2014
he mean this i think
pawn Код:
format(string, sizeof(string), "Kills: [%d] - Deaths: [%d] - K/D Ratio: [%.2f] ", PlayerInfo[playerid][Kills], PlayerInfo[playerid][Deaths], floatdiv(PlayerInfo[playerid][Kills], PlayerInfo[playerid][Deaths]));
Edit: too late
Re: Need help with kill/death ratio -
barts - 15.02.2014
Thanks to Konstantinos and BlackBomb, it is working now.+REP fo you guys