• Log in or sign up for an account here: https://www.sythe.org/login

Index Out Of Range

  • Thread starter Thread starter Anime
  • Start date Start date
A

Anime

Guest
Code:
Code:
var
  Mobiles : array of TNPC;
  Index : Integer;
begin
  Mobiles := GetNPCsByID( mobile );
  for Index := 0 to GetArrayLength( Mobiles ) - 1 do
    begin
    Writeln( 'Index: ' + IntToStr( Index ) );
    Writeln( 'Name: ' + Mobiles[Index].name );
    Writeln( 'ID: ' + IntToStr( Mobiles[Index].NPCType ) );
  end;
  if not TileOnMS( Mobiles[0].tile, Player.Height ) then
  begin
    WalkToTile( Mobiles[0].tile, 5, 1 );
    Wait( 500 + Random( 250 ) );
  end;
    Result := TileToMS( Mobiles[0].tile, Player.Height );
end;

I used this as a way to check the index of the NPC I'm looking for:
Code:
for Index := 0 to GetArrayLength( Mobiles ) - 1 do
    begin
    Writeln( 'Index: ' + IntToStr( Index ) );
    Writeln( 'Name: ' + Mobiles[Index].name );
    Writeln( 'ID: ' + IntToStr( Mobiles[Index].NPCType ) );
  end;
The index of the NPC that I'm lookng for was '0'.

My script crashes when I use:
Code:
  if not TileOnMS( Mobiles[0].tile, Player.Height ) then
I get a out of range error.

How can it be out of range if it printed Mobiles[0] in the debug?
 
Runescape Gamblingrunescape gambling
Back
Top