Ratio bug! - Printable Version
+- SA-MP Forums Archive (
https://sampforum.blast.hk)
+-- Forum: SA-MP Scripting and Plugins (
https://sampforum.blast.hk/forumdisplay.php?fid=8)
+--- Forum: Scripting Help (
https://sampforum.blast.hk/forumdisplay.php?fid=12)
+--- Thread: Ratio bug! (
/showthread.php?tid=658610)
Ratio bug! -
GameOvr - 08.09.2018
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!
Re: Ratio bug! -
severance - 08.09.2018
maybe instead of this
you do
Re: Ratio bug! -
Calisthenics - 08.09.2018
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));
Re: Ratio bug! -
UFF - 08.09.2018
Код:
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