PDA

View Full Version : Can you find out whats wrong with my script?



mohua
10-20-2006, 08:25 PM
I was working on my first script, (an autofighter) and i cant find out whats wrong with it!
It will work at first, it fights 1 monster, then i get this error:

[Runtime Error] : Out Of Range in line 65 in script C:\Program Files\SCAR 2.03\includes\SRL/SRL/Skill/Fighting.scar

Heres the script:

program AutoFighter1;

{.include SRL/SRL.scar}
{.include SRL/SRL/Skill/Fighting.scar}
{.include SRL/SRL/extended/xAntiRandoms.scar}

Const
Color1= 15001575; //
Color2= 10332585; //
Color3= 1454660; //
Color4= 15001575; //
Color5= 10332585; //
Color6= 1454660; //
tol=5; //
fightmode=1; //fightmode to use, 1-4
monsterstokill=1000; //Number of monsters you want to kill

Var
Killed: Integer;
Scriptl: Integer;
TimeOut: Integer;

procedure startup;
begin
SetupSRL;
FindRs;
PerfectNorth;
end;

procedure ABan;
begin
RotateEvery(5);
AntiBan;
FindMod;
RandomMovement;
BoredHuman;
end;

procedure Fighting;
begin if not InFight then begin
FightNPC(Color1, Color2, Color3, Color4, Color5, Color6, tol, TimeOut);
killed:=killed+1
end; end;

procedure Progressreport;
begin
writeLn('Progress report')
writeLn('killed: ' +inttostr(killed)+' monsters so far')
writeLn('End Report')
end;

begin
Startup;
SetFightMode(FightMode);
repeat
ABan;
FindNormalRandoms;
progressreport;
Fighting;
until(killed=monsterstokill);
Logout;
Writeln('Finished Fighting, Logout')
end.

I Pick Axes
10-20-2006, 09:33 PM
Usually that means you're supplying something with a value it can't use although the type is correct.

The offending line is:

Players[CurrentPlayer].Killed:=Players[CurrentPlayer].Killed+1;

This is setting a value in the player array. The thing is, you don't have a player array. So it tries to write to a nonexistent array, and fails.

http://www.villu-reborn.com/showthread.php?t=2506

explains what you have to do to set up a player array.

mohua
10-20-2006, 10:02 PM
Thanks!