open.mp forum
[Pawn] Divide by zero - Printable Version

+ open.mp forum (https://forum.open.mp)
-- Forum: SA-MP (https://forum.open.mp/forumdisplay.php?fid=3)
--- Forum: Pawn Scripting (https://forum.open.mp/forumdisplay.php?fid=10)
--- Thread: [Pawn] Divide by zero (/showthread.php?tid=1564)



Divide by zero - Zow - 2021-01-20

Code:
ExpProgress(playerid)

{

? ? new Float:exp = playerData[playerid][pExp]*100/PlayerRequiredExp(playerid);

? ? return exp;

}



PlayerRequiredExp(playerid)

{

? ? new requiredexp = playerData[playerid][pLevel] * 2000;

return requiredexp;

}



pExp are always start from 0 when you're level up

So crashdetect always give me this?Run time error 11: "Divide by zero"

I need some idea how to get pass this one

I just want to popup exp to % but I need pExp to start by 0 when level up

Is that possible?


RE: Divide by zero - RhaegarX - 2021-01-20

PHP Code:
ExpProgress(playerid)
{
? ? return 
playerData[playerid][pExp] == :?playerData[playerid][pExp]*100/PlayerRequiredExp(playerid);



I think doing this check should work, try testing.