SRL Archive - Help and Support

Runtime error


The Un-Named

2006-06-20 12:33:37

[Runtime Error] : divide by Zero in line 419 in script C:\Documents and Settings\****\Desktop\srl\srl\core\GameTab.scar

Not happend before but it randomly happens while I'm testing my new(and soon to be released) autofighter.

I have SetupSRL in my main loop and if you think you know what's causing the problem, pm me for the script.

c0de

2006-06-20 13:02:30


{*******************************************************************************
function HpPercent : Integer;
By: RsN
Description: Returns Hp left as a percentage
*******************************************************************************}
function HpPercent : Integer;
var
tlevel, tamount : Integer;
begin
tlevel := GetSkillLevel('hitpoints');
tamount := GetSkillAmount('hitpoints');
Result := (tamount * 100) / tlevel;
end;

It tries to get skill level but due to rs update, I think it is broken and that's why it returns zero and further code tries to divide with it, that's where SCAR Dies, because dividing with zero is not possible.

The Un-Named

2006-06-21 14:16:00

Haha, thanks. ;)

Roberty Bob

2006-06-26 09:30:37

so that is why mining scripts are dying too. becuase when a fight random comes along ??

I've had this error a few times. thanks c0de

The Un-Named

2006-06-26 16:59:19

No, when you use HPPercent.

Spky

2006-06-26 17:23:26

From: The Un-Named
No, when you use HPPercent.


Yes because it checks the Hp when a fighting random comes. I think…

XxKanexX

2006-06-27 02:22:21

Here you go, shouldn't get the error anymore:


{*******************************************************************************
function HpPercent : Integer;
By: RsN
Description: Returns Hp left as a percentage
*******************************************************************************}
function HpPercent : Integer;
var
tlevel, tamount : Integer;
begin
tlevel := GetSkillLevel('hitpoints');
tamount := GetSkillAmount('hitpoints');
if (tlevel <= 0) then
begin
Result:= 0;
Exit;
end;
Result := (tamount * 100) / tlevel;
end;