Ratio bug!
#1

Hello, I have a ratio problem , It is...

* When I'm in DM if I have 0 deaths with any number of kills it's not working IDK why, but if I have even 1 death it is working without any errors

here's a pic of ratio when I have 0 deaths with 4 kills:


here's a pic of ratio when I have 1 death with 4 kills:


here's my code:
Код:
//under OnPlayerDeath
format(str4, sizeof(str4), "ratio:_%.2f", floatdiv(DMKILLS[killerid], DMDEATHS[killerid]));
format(str5, sizeof(str5), "ratio:_%.2f", floatdiv(DMKILLS[playerid], DMDEATHS[playerid]));
PlayerTextDrawSetString(killerid, DM5, str4);
PlayerTextDrawSetString(playerid, DM5, str5);
THANKS!
Reply
#2

maybe instead of this
PHP код:
_%.2f 
you do
PHP код:
%.2f 
Reply
#3

It cannot divide with zero. You can use a temporary variable and set its value to one just for the division.
pawn Код:
new deaths_of_playerid = !DMDEATHS[playerid] ? 1 : DMDEATHS[playerid],
    deaths_of_killerid = !DMDEATHS[killerid] ? 1 : DMDEATHS[killerid];

format(str4, sizeof(str4), "ratio:_%.2f", floatdiv(DMKILLS[killerid], deaths_of_killerid));
format(str5, sizeof(str5), "ratio:_%.2f", floatdiv(DMKILLS[playerid], deaths_of_playerid));
Reply
#4

Код:
format(str4, sizeof(str4), "ratio:%0.2f", Float:DMKILLS[killerid]/Float:DMDEATHS[killerid]);
format(str5, sizeof(str5), "ratio:%0.2f", Float:DMKILLS[playerid]/Float:DMDEATHS[playerid]);
PlayerTextDrawSetString(killerid, DM5, str4);
PlayerTextDrawSetString(playerid, DM5, str5);
try this
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)