Nadeem
2009-05-01 06:44:09
Hi everyone!
I've been recoding one of my scripts, and currently I've come across a horrific runtime error :( I get this error:
[Runtime Error] : Out of Proc Range in line 165 in script C:\Program Files\SCAR 3.20\Scripts\Multi-Agility Trainer\Multi-Agility Trainer [2.00] [Nadeem].scar
My code is here:
Thank you for all help!!
Edit: Although I might temporary replace it with Agility.Find() - That seems to work….
I've been recoding one of my scripts, and currently I've come across a horrific runtime error :( I get this error:
[Runtime Error] : Out of Proc Range in line 165 in script C:\Program Files\SCAR 3.20\Scripts\Multi-Agility Trainer\Multi-Agility Trainer [2.00] [Nadeem].scar
My code is here:
{------------------------------------------------------------------------------}
{.include SRL/SRL/misc/Smart.scar }
{.include SRL/srl.scar }
{.include SRL/SRL/skill/Agility.scar }
{$DEFINE DebugMode }
{------------------------------------------------------------------------------}
{===============================Player Setup===================================}
{------------------------------------------------------------------------------}
const
SendTXTIngame = True;
WorldNum = 157;
Member = True;
Signed = True;
TheMouseSpeed = 13;
RanMouseSpeed = 16;
SRLStatsId = '7175';
SRLStatsPass = 'nadeem';
procedure DeclarePlayers;
begin
HowManyPlayers := 1; //Change this accordingly
NumberOfPlayers(HowManyPlayers); // Total Number Of Players
CurrentPlayer := 0; // The Current Player To Start With
Players[0].Name := ''; // Character Name
Players[0].Pass := ''; // Character Pass
Players[0].Nick := ''; // Nickname 3 - 4 Letter's of char name
Players[0].Integers[0] := 1000; // Total Laps To Do
Players[0].Integers[1] := 1; // Course to do. (See top for course codes);
Players[0].Booleans[0] := True; // True if you want to run, False to walk
Players[0].Active := True; // True to use player, False if else
{
Players[1].Name := '';
Players[1].Pass := '';
Players[1].Nick := '';
Players[1].Integers[0] := 1000;
Players[1].Booleans[0] := True;
Players[1].Active := True;
}
end;
{------------------------------------------------------------------------------}
{===========No Need To Edit Below Unless You Know What Your Doing :)===========}
{------------------------------------------------------------------------------}
const
ScriptName = 'Multi-Agility Trainer';
Version = '2.00';
type
TAgilityFuncs = record
Course: string;
XP: Extended;
Complete: array [0..10] of Boolean;
Setup, Obstacle: procedure;
Load, Clear: procedure(ID: Integer);
Failsafe: procedure(ID, Loc: Integer);
Locate: function(ID: Integer): string;
Find: function(var fx, fy: Integer; ID: Integer): Boolean;
end;
TLocalVars = record
Nick, Weight, Loc: string;
Laps, LapsDone, Leveled, XP: Integer;
Failsafes, AntiBans, TimeRan: Integer;
TimeStart, TimeEnd: Integer;
Active, Run: Boolean;
Nadeem: TAgilityFuncs;
Start: procedure;
end;
TLocalVarsArray = array [0..10] of TLocalVars;
var
Agility: TAgilityFuncs;
Local: TLocalVarsArray;
{*********************************************************************
* Procedure : ns_Warn; | v1.0 *
* Author : Nadeem *
* Desc. : Sends out a alert message in debug box. *
*********************************************************************}
procedure ns_Warn(Str: string; ClearDB, EndScript: Boolean);
begin
if ClearDB then ClearDebug;
Writeln('********* ' + Str + ' *********');
if EndScript then TerminateScript;
end;
{*********************************************************************
* Procedure : LoadObstacles; | v1.0 *
* Author : Nadeem *
* Desc. : Loads an obstacles information. *
*********************************************************************}
procedure LoadObstacles(ID: Integer);
begin
end;
{*********************************************************************
* Procedure : ClearObstacles; | v1.0 *
* Author : Nadeem *
* Desc. : Clears an an obstacles information. *
*********************************************************************}
procedure ClearObstacles(ID: Integer);
begin
end;
{*********************************************************************
* Procedure : Failsafe; | v1.0 *
* Author : Nadeem *
* Desc. : Performs failsafe based on ID. *
*********************************************************************}
procedure Failsafe(ID, Loc: Integer);
begin
end;
{*********************************************************************
* Function : Locate: string; | v1.0 *
* Author : Nadeem *
* Desc. : Finds and sets the current location of player. *
*********************************************************************}
function Locate(ID: Integer): string;
begin
case ID of
1 : begin
Result := 'Gnome';
end;
2 : begin
Result := 'Barbarian';
end;
end;
end;
{*********************************************************************
* Function : FindObstacle: Boolean; | v1.0 *
* Author : Nadeem *
* Desc. : Find the obstacle being looked for. *
*********************************************************************}
function FindObstacle(var fx, fy: Integer; ID: Integer): Boolean;
begin
GetMousePos(fx, fy);
Result := True;
end;
{*********************************************************************
* Procedure : GnomeCourse; | v1.0 *
* Author : Nadeem *
* Desc. : Peforms agility training at the Gnome Course. *
*********************************************************************}
procedure GnomeCourse;
var
x, y: Integer;
C, TriesFailsafe, TriesToDo, Tries: Integer;
label
_2;
begin
{$IFDEF DebugMode} Writeln('GnomeCourse'); {$ENDIF}
C := CurrentPlayer;
TriesFailsafe := 1;
TriesToDo := 3;
with Local[C] do
begin
if(not(Nadeem.Complete[0]))then
begin
if Nadeem.Find(x, y, 0) then
begin
end else if (Tries >= TriesFailsafe) then
begin
Nadeem.Failsafe(1, 0);
Exit;
end else if (Tries >= TriesToDo) then
begin
Nadeem.Locate(1);
Exit;
end;
end;
if(not(Nadeem.Complete[1]))then
begin
if Nadeem.Find(x, y, 1) then
begin
end else if (Tries >= TriesFailsafe) then
begin
Nadeem.Failsafe(1, 1);
Exit;
end else if (Tries >= TriesToDo) then
begin
Nadeem.Locate(1);
Exit;
end;
end;
if(not(Nadeem.Complete[2]))then
begin
_2:
if Nadeem.Find(x, y, 2) then
begin
end else if (Tries >= TriesFailsafe) then
begin
Nadeem.Failsafe(1, 2);
goto _2;
end else if (Tries >= TriesToDo) then
begin
Nadeem.Locate(1);
Exit;
end;
end;
if(not(Nadeem.Complete[3]))then
begin
if Nadeem.Find(x, y, 3) then
begin
end else if (Tries >= TriesToDo) then
begin
Nadeem.Locate(1);
Exit;
end;
end;
if(not(Nadeem.Complete[4]))then
begin
if Nadeem.Find(x, y, 4) then
begin
end else if (Tries >= TriesToDo) then
begin
Nadeem.Locate(1);
Exit;
end;
end;
if(not(Nadeem.Complete[5]))then
begin
if Nadeem.Find(x, y, 5) then
begin
end else if (Tries >= TriesToDo) then
begin
Nadeem.Locate(1);
Exit;
end;
end;
if(not(Nadeem.Complete[6]))then
begin
if Nadeem.Find(x, y, 6) then
begin
end else if (Tries >= TriesToDo) then
begin
Nadeem.Locate(1);
Exit;
end;
end;
if(not(Nadeem.Complete[7]))then
begin
if Nadeem.Find(x, y, 7) then
begin
end else if (Tries >= TriesToDo) then
begin
Nadeem.Locate(1);
Exit;
end;
end;
end;
end;
{*********************************************************************
* Procedure : StartTraining; | v1.0 *
* Author : Nadeem *
* Desc. : Start training the player. (loop) *
*********************************************************************}
procedure StartTraining;
var
C: Integer;
Complete: Boolean;
begin
while (not(Complete)) do
begin
{$IFDEF DebugMode} Writeln('StartTraining'); {$ENDIF}
C := CurrentPlayer;
SetRun(Local[C].Run);
Agility.Obstacle();
if (Local[C].LapsDone >= Local[C].Laps) then
Complete := True;
end;
end;
{*********************************************************************
* Procedure : AgilitySetup; | v1.0 *
* Author : Nadeem *
* Desc. : Setup agility course. *
*********************************************************************}
procedure AgilitySetup;
begin
{$IFDEF DebugMode} Writeln('AgilitySetup'); {$ENDIF}
with Local[CurrentPlayer] do
begin
Nick := Players[CurrentPlayer].Nick;
Loc := '';
Laps := Players[CurrentPlayer].Integers[0];
Run := Players[CurrentPlayer].Booleans[0];
TimeStart := GetSystemTime;
TimeEnd := -1;
Start := @StartTraining;
end;
end;
{*********************************************************************
* Procedure : LoadFuncs; | v1.0 *
* Author : Nadeem *
* Desc. : Loads all functions associated with current course. *
*********************************************************************}
procedure LoadFuncs(ID: Integer);
var
i: Integer;
begin
{$IFDEF DebugMode} Writeln('LoadFuncs: ' + IntToStr(ID)); {$ENDIF}
case ID of
1 : begin
try
with Agility do
begin
Course := 'Gnome Course';
XP := GetCourseXP(Course);
Setup := @AgilitySetup;
Load := @LoadObstacles;
Clear := @ClearObstacles;
Obstacle := @GnomeCourse;
Failsafe := @Failsafe;
Locate := @Locate;
Find := @FindObstacle;
for i := 0 to 10 do
Complete[i] := False;
end;
finally
ns_Warn('Gnome Agility Course | LOADED', false, false);
except
ns_Warn('Gnome Agility Course | Unable to load. Please report this', true, true);
end;
end;
2 : begin
try
with Agility do
begin
Course := 'Barbarian Outpost';
XP := GetCourseXP(Course);
Setup := nil;
Load := nil;
Clear := @ClearObstacles;
Obstacle := nil;
Failsafe := @Failsafe;
Locate := @Locate;
Find := @FindObstacle;
for i := 0 to 10 do
Complete[i] := False;
end;
finally
ns_Warn('Barbarian Outpost | Coming Soon!', true, false);
except
ns_Warn('Barbarian Outpost | Unable to load. Please report this', true, true);
end;
end;
end;
end;
{*********************************************************************
* Procedure : ScriptSetup; | v1.0 *
* Author : Nadeem *
* Desc. : Starts cutting tree. *
*********************************************************************}
procedure ScriptSetup;
begin
SmartSetupEx(155, True, True, False);
SetTargetDC(SmartGetDC);
while (SmartGetColor(253, 233) = 1118604) do
Wait(100);
SetupSRL;
Disguise('Windows Live Hotm...');
Status('Starting ' + ScriptName + ' v' + Version);
try
DeclarePlayers;
finally
if (HowManyPlayers > 1) then
ns_Warn('Multi-Player Mode', true, false)
else
ns_Warn('Single Player Mode', true, false);
except
ns_Warn('Unable to load Players. Please Re-Check DeclarePlayers.', true, true);
end;
ActivateClient;
if(not(LoggedIn))then LoginPlayer;
SetChat('off', 4);
SetChat('off', 5);
end;
begin
ClearDebug;
ClearReport;
ScriptSetup;
LoadFuncs(Players[CurrentPlayer].Integers[1]);
Agility.Setup();
Local[CurrentPlayer].Start();
end.
Thank you for all help!!
Edit: Although I might temporary replace it with Agility.Find() - That seems to work….