Log in

View Full Version : ACA giving range check error?



i need to bot!
03-10-2012, 01:13 PM
So, i use ACA to find the bank booth colour, then findobjcustom to click it- but after it has been clicked I get a 'range check error'? any ideas?

the script:
program MehScript;

{$i srl/srl.simba}

procedure DeclarePlayers;
begin
HowManyPlayers:= 1;
NumberOfPlayers(HowManyPlayers);
CurrentPlayer := 0;

Players[0].Name := '';
Players[0].Pass := '';
Players[0].Nick := '';
Players[0].Pin := '';
Players[0].Active := true;
LoginPlayer
end;

var
x, y: integer;

function potcol: Integer;
var
arP: TPointArray;
arC: TIntegerArray;
tmpCTS, i, arL: Integer;
X, Y, Z: Extended;
begin
tmpCTS := GetColorToleranceSpeed;
ColorToleranceSpeed(2);
SetColorSpeed2Modifiers(0.03, 0.12);

FindColorsSpiralTolerance(MSCX, MSCY, arP, 3428981, MSX1, MSY1, MSX2, MSY2, 8);
if (Length(arP) = 0) then
begin
Writeln('Failed to find the color, no result.');
ColorToleranceSpeed(tmpCTS);
SetColorSpeed2Modifiers(0.2, 0.2);
Exit;
end;

arC := GetColors(arP);
ClearSameIntegers(arC);
arL := High(arC);

for i := 0 to arL do
begin
ColorToXYZ(arC[i], X, Y, Z);

if (X >= 6.61) and (X <= 16.80) and (Y >= 6.08) and (Y <= 15.33) and (Z >= 2.81) and (Z <= 6.79) then
begin
Result := arC[i];
Writeln('AutoColor = ' + IntToStr(arC[i]));
Break;
end;
end;

ColorToleranceSpeed(tmpCTS);
SetColorSpeed2Modifiers(0.2, 0.2);

if (i = arL + 1) then
Writeln('AutoColor failed in finding the color.');
end;

procedure move1; //works perfectly
var
x, y, wai1: Integer;
begin
wai1 := DTMFromString('mwQAAAHic42RgYIhiYmCoAuJWIJ4NxDOBeA 4UFwJxERArA9UVAHEhlE4C4jggjgTiXCBOBmILY3UGH19VBu88 czDt4KjA0OzBzZBpK8jg5a7M4GAnzyAJVEcIMxKB4QAAx4kPiA ==');
begin
if DTMRotated(wai1, x, y, MMX1, MMY1, MMX2, MMY2) then
begin
Mouse (x, y, 0, 0, true);
writeln('wai1!');
end;
end;
end;

function boothcol: Integer;
var
arP: TPointArray;
arC: TIntegerArray;
tmpCTS, i, arL: Integer;
X, Y, Z: Extended;
begin
tmpCTS := GetColorToleranceSpeed;
ColorToleranceSpeed(2);
SetColorSpeed2Modifiers(0.11, 7.42);

FindColorsSpiralTolerance(MSCX, MSCY, arP, 1653317, MSX1, MSY1, MSX2, MSY2, 1);
if (Length(arP) = 0) then
begin
Writeln('Failed to find the color, no result.');
ColorToleranceSpeed(tmpCTS);
SetColorSpeed2Modifiers(0.2, 0.2);
Exit;
end;

arC := GetColors(arP);
ClearSameIntegers(arC);
arL := High(arC);

for i := 0 to arL do
begin
ColorToXYZ(arC[i], X, Y, Z);

if (X >= 4.03) and (X <= 4.93) and (Y >= 4.23) and (Y <= 5.17) and (Z >= 1.30) and (Z <= 1.89) then
begin
Result := arC[i];
Writeln('AutoColor = ' + IntToStr(arC[i]));
Break;
end;
end;

ColorToleranceSpeed(tmpCTS);
SetColorSpeed2Modifiers(0.2, 0.2);

if (i = arL + 1) then
Writeln('AutoColor failed in finding the color.');
end;
procedure openbank1;
begin
if findobjcustom(x, y, ['ank'], [boothcol], 2) then
Mouse(x, y, 0, 0, true);
end;
procedure withdraw1;
begin
if findobjcustom(x, y, ['ot'], [potcol], 2) then
Mouse(x, y, 0, 0, false);
chooseoption ('ithdraw-14');
end;
procedure camera;
begin
makecompass(90);
end;


begin
SetupSRL;
boothcol;
potcol;
DeclarePlayers;
openbank1;
withdraw1;
move1;
camera;
end.

the error: Exception: Range check error at line 34

i really don't get this.. the script just failes after clicking once

thanks :D

davis_junior
03-13-2012, 11:27 AM
It's probably because the TPA "arP" doesn't exist because no color was found.

To check if the function found the color, you should use FindColorsSpiralTolerance()'s result, like so:


if (not FindColorsSpiralTolerance(MSCX, MSCY, arP, 3428981, MSX1, MSY1, MSX2, MSY2, 8)) then
begin
Writeln('Failed to find the color, no result.');
ColorToleranceSpeed(tmpCTS);
SetColorSpeed2Modifiers(0.2, 0.2);
Exit;
end;


Replace lines 33-39 with the above code.