SRL Archive - Help

Error: divide by Zero at line 322


QAZ

2012-06-06 16:28:56

anybody know how to fix this error, will save my whole proggy on script, can't figure it out. thanks

DRose

2012-06-06 16:35:37

Think you change the player integer to 0 if you have 1 in the script

Rich

2012-06-06 16:36:45

Think you could post line 322?

Main

2012-06-06 16:36:59

Post the procedure.

Also if you have a division like X/Y try



X/(Y+1)

isntead of
X/Y

YoHoJo

2012-06-06 16:37:06

Post entire script/procedure.

QAZ

2012-06-06 16:39:26

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

2012-06-06 16:47:36

From: Main
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

2012-06-06 16:56:07

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

2012-06-06 17:01:42

From: Main
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