Log in

View Full Version : Error: divide by Zero at line 322



QAZ
06-06-2012, 08:28 PM
anybody know how to fix this error, will save my whole proggy on script, can't figure it out. thanks

DRose
06-06-2012, 08:35 PM
Think you change the player integer to 0 if you have 1 in the script

Rich
06-06-2012, 08:36 PM
Think you could post line 322?

Main
06-06-2012, 08:36 PM
Post the procedure.

Also if you have a division like X/Y try



X/(Y+1)

isntead of
X/Y

YoHoJo
06-06-2012, 08:37 PM
Post entire script/procedure.

QAZ
06-06-2012, 08:39 PM
ok, btw this isn't my script i'm fixing up somebodys cooker script with permission but any here it is


procedure:

procedure PrintProggy; // proggys
var
CookPerHour:Integer;
begin
ClearDebug;
CookPerHour := (Round((FishCooked * 3600) / (GetTimeRunning / 1000)))

writeln(' ');
writeln('~~~~~~~~~~ Al Kharid Cooker by Chris ~~~~~~~~~~');
writeln('Cooking Fish: ' + Fish2Cook + ' Cooked: ' + inttostr(FishCooked) + ',' + ' Burned: ' +
inttostr(FishBurned) + '.');
writeln(' Experience Gained: ' + inttostr(FishCooked * XpPerFish));
writeln(' Time Ran: ' + TimeRunning);
writeln(' Cooking per hour: ' + inttostr(CookPerHour));
writeln(' Experience per hour: ' + inttostr(CookPerHour*XpPerFish));
writeln(' Current Activity: ' + DoingATM);
if AddToStats then
begin
IncVars;
Stats_Commit;
end;
end;




line:

CookPerHour := (Round((FishCooked * 3600) / (GetTimeRunning / 1000)))

Sex
06-06-2012, 08:47 PM
Post the procedure.

Also if you have a division like X/Y try



X/(Y+1)

isntead of
X/Y


No, try. Literally.

try x := y/z; except end;

Main
06-06-2012, 08:56 PM
Lol sex, yeah forgot about that.

But erm


(Round((FishCooked * 3600) / (GetTimeRunning / 1000)))

GetTimeRunning/1000 is the amount of second you have run. Try

FishCooked*GetTimeRunning/3600000;


Example:

If FishCooked is 500 and the script have be run for half hour:
500*1800000/36000000=250 :)

No need to worry about divide by 0.

QAZ
06-06-2012, 09:01 PM
Lol sex, yeah forgot about that.

But erm


(Round((FishCooked * 3600) / (GetTimeRunning / 1000)))

GetTimeRunning/1000 is the amount of second you have run. Try

FishCooked*GetTimeRunning/3600000;


Example:

If FishCooked is 500 and the script have be run for half hour:
500*1800000/36000000=250 :)

No need to worry about divide by 0.



you sir, are a genius.

it worked :D