SRL Archive - OSR Help

Out of range error


KingKong

2010-12-28 06:05:23

I get an out of range error and I am unable to come up with any idea why its happening, can someone point out what i've done wrong here.

P.S. All of the functions/procedure work perfectly its only the repeat loop thats giving me the problems for some strange reason)

repeat
while (GetAnimation = -1) and (not R_InvFull) do
begin
StartFishing;
CheckRandomArea(3101, 3436, 3111, 3422);
wait(2000);
while (a < 5) and (CharacterMoving) do
begin
wait(1000);
CheckRandomArea(3101, 3436, 3111, 3422);
end;
a := 0;
while (not R_InvFull) and (GetAnimation = 623) do
begin
wait(200);
CheckRandomArea(3101, 3436, 3111, 3422);
end;
end;
fishes[0] := fishes[0] + R_CountItemID(331); //salmon
fishes[1] := fishes[1] + R_CountItemID(335); //trout
R_DropAllItemsIDEx([335, 331]);
Inc(loads);
writeln('Running for: ' + TimeRunning);
writeln('Loads done: ' + IntToStr(loads));
writeln('Fishing exp: ' + IntToStr(70 * fishes[0] + 50 * fishes[1]));
until(loads = Players[0].Integers[0]); //<================ Error here!!!!!!!

EDIT: SOLVED

Capricorn

2010-12-28 06:11:44

Out of range errors mean you are trying to access/write to an element of an array that doesn't exist.

KingKong

2010-12-28 06:26:41

Nvm, I forgot to write DeclarePlayers in my script which holds Playeres[0].Integers[0]

KingKong

2010-12-30 22:40:43

Does anyone know how to setlength's of more than one variable at the same time?

Edit: Sry for the double post, but i didn't want to make another thread just for this one question

i luffs yeww

2010-12-31 01:02:36

Kong, you can't, unless you make your own procedure/function.


procedure SetLengthEx(Arrays: array of TIntegerArray; Lengths: TIntegerArray);
var
i: Integer;
begin
for i := 0 to High(Arrays) do
SetLength(Arrays[i], Lengths[i]);
end;

Might work?

KingKong

2010-12-31 01:28:58

With that method, wouldn't it only work with integer arrays? if i had different types of arrays, then wouldn't it become really messy?

Frement

2010-12-31 01:34:36

TVariantArray

But I don't think it can be done that way. Just set the lengths as you normally do for all of the arrays.

i luffs yeww

2010-12-31 13:04:07

For some reason I thought that you could only set the lengths of TIntegerArrays.. :3

But yeah, I really don't think you can with a loop or anything.