Float (Problem) - 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: Float (Problem) (
/showthread.php?tid=365754)
Float (Problem) -
[SF]OutLawZ - 04.08.2012
Hello,
Run time error 11: "Devide by zero"
I've managed to find the problem in my script which leads to these lines;
Код:
new Float:kr;
kr = (g_playerdata[pid][KILLS]/g_playerdata[pid][DEATHS]);
format(string, sizeof(string), "{EBD113}(Kills/Deaths) {FFFFFF}Kills -> %i .. Drive-by kills - > %i .. Deaths -> %i .. Suicides -> %i .. Ratio -> %.2fm", g_playerdata[pid][KILLS], g_playerdata[pid][DBKILLS], g_playerdata[pid][DEATHS], g_playerdata[pid][SUICIDES],kr);
SendPlayerInfo(playerid, string);
The Ratio -> %.2fm code tends to appear as an 'unknown command' ?
I have used new Float:kr; but doesn't work.
Any suggestions would be appreciated. Thanks
Re: Float (Problem) -
Ricop522 - 04.08.2012
Try to print the KR.
I dont know but, change:
%.2fm
to
%.2f
without the 'm'
Re: Float (Problem) -
[MM]RoXoR[FS] - 04.08.2012
You must check if deaths are not equal to 0, if death is 0, you must not divide.
Re: Float (Problem) -
[SF]OutLawZ - 04.08.2012
Okay, I see.
Re: Float (Problem) -
[MM]RoXoR[FS] - 04.08.2012
pawn Код:
new Float:kr;
//______________
if(g_playerdata[pid][DEATHS] == 0)
format(string, sizeof(string), "{EBD113}(Kills/Deaths) {FFFFFF}Kills -> %i .. Drive-by kills - > %i .. Deaths -> %i .. Suicides -> %i .. Ratio -> N/A", g_playerdata[pid][KILLS], g_playerdata[pid][DBKILLS], g_playerdata[pid][DEATHS], g_playerdata[pid][SUICIDES]);
else
{
kr = (g_playerdata[pid][KILLS]/g_playerdata[pid][DEATHS]);
format(string, sizeof(string), "{EBD113}(Kills/Deaths) {FFFFFF}Kills -> %i .. Drive-by kills - > %i .. Deaths -> %i .. Suicides -> %i .. Ratio -> %.2fm", g_playerdata[pid][KILLS], g_playerdata[pid][DBKILLS], g_playerdata[pid][DEATHS], g_playerdata[pid][SUICIDES],kr);
}
//______________
SendPlayerInfo(playerid, string);
Re: Float (Problem) -
[SF]OutLawZ - 04.08.2012
Thank you, your code works fine.