Results 1 to 12 of 12

Thread: [Runtime Error] : Out Of Range in line 139 in script

  1. #1
    Join Date
    Feb 2009
    Posts
    2,155
    Mentioned
    4 Post(s)
    Quoted
    42 Post(s)

    Default [Runtime Error] : Out Of Range in line 139 in script

    Code:
    {.include srl/srl.scar}
    
    var
      x, y, cactuscolor:integer;
    
    procedure DeclarePlayers;//add more if needed
    begin
      HowManyPlayers := 1;
      NumberOfPlayers(HowManyPlayers);
      CurrentPlayer := 0;
      Players[0].Name       := '';
      Players[0].Pass       := '';
      Players[0].Nick       := '';
      Players[0].Active     := True;    // Use this account?
      Players[0].strings[0]:= 'runite'; // what bar to smith
      players[0].pin:='';//bank pin
      Players[0].BoxRewards := ['XP', 'ostume', 'mote', 'Gem', 'ithril', 'oal'];
    end;
    
    procedure banker;
    begin
      openbankfast('akb');
      if bankscreen or pinscreen then
      begin
        writeln('opened bank');
      end else
      openbankglass('akb', true, true);
      if bankscreen or pinscreen then
      begin
        writeln('opened bank');
      end else
      Writeln('could not open bank.');
      if pinscreen then inpin(players[0].strings[1]);
    end;
    
    procedure getore;
    var
      mainamount, secamount : integer;
    begin
      case (Lowercase(Players[CurrentPlayer].Strings[0])) of
        'bronze':
        begin
          mainamount := 14;
          secamount:= 14;
        end;
        'iron':
        begin
          mainamount := 28; // Fill the acutal amounts in for the following though.
          secamount:= 0;
        end;
        'steel':
        begin
          mainamount := 9;
          secamount:= 18;
        end;
        'mithril':
        begin
          mainamount := 5;
          secamount:= 20;
        end;
        'addy':
        begin
          mainamount := 4;
          secamount:= 24;
        end;
        'runite':
        begin
          mainamount := 3;
          secamount:= 24;
        end;
        else Writeln('incorrect speeling srry');
      end;
      Withdraw(1, 1, mainamount);
      wait(100 + random(200));
      Withdraw(2, 1, secamount);
    end;
      
      
      
      
      
      
      
    function FindCactusColor: Integer;
    var
      GC, a, l, TestColor: integer;
    var
      P:array of Tpoint;
    Begin
      if CactusColor = 0 then
      Begin
        GC := 3502663;
        Flag;
        FindColorsSpiralTolerance(MMCX,MMCY, P, GC, MMX1,MMY1,MMX2,MMY2, 75);
        l:=GetArrayLength(P);
        for a:= 0 to l-1 do
        begin
          TestColor := GetColor(P[a].x,P[a].y);
          if (GetColor(P[a].x,P[a].y + 1)=TestColor-1708041) then
          begin
            Result := TestColor;
            CactusColor:=Result;
            writeln('Cactus Color = ' + IntToStr(TestColor));
            Exit;
          end;
        end;
      writeln('Could not find Cactus Color!');
      Result := 0;
      end;
    end;
    
    procedure tofurnace;
    begin
      radialwalk(cactuscolor, 0, 140, 100, 1, 1);
      flag;
      if findcolortolerance(x, y, 127739, mmx1, mmy1, mmx2, mmy2,15) then
      begin
        mouse(x, y, 3, 3, true);
        writeln('found funace')
        flag;
      end;
    end;
    
    procedure findfurnace;
    begin
      makecompass('w');
      if findcolortolerance(x, y, 3289654, msx1, msy1, msx2, msy2, 15) then
      begin
        mouse(x,y,3,3,false);
        wait(100 + random (20));
        chooseoption('melt');
      end;
    end;
    
    procedure choosebar;
    var
      barcolor, amount : integer;
    begin
      case (Lowercase(Players[CurrentPlayer].Strings[0])) of
        'bronze':
        begin
          barcolor := 2374477;
          amount:= 14;
        end;
        'iron':
        begin
          barcolor := 5000274;
          amount := 28;
        end;
        'steel':
        begin
          barcolor := 7303288;
          amount:= 9;
        end;
        'mithril':
        begin
          barcolor := 6111295;
          amount := 5;
        end;
        'addy':
        begin
          barcolor := 4280641;
          amount := 4;
        end;
        'runite':
        begin
          barcolor := 6510915;
          amount := 3;
        end;
        else Writeln('failed to select bar srry');
      end;
      if findcolortolerance(x, y, barcolor, msx1, msy1, msx2, msy2, 15) then
        mmouse(x,y,3,3);
        if(isuptext(Lowercase(Players[CurrentPlayer].Strings[0]))) then
        begin
          mouse(x, y, 3, 3, false);
          wait(100 + random(20));
          chooseoption('X');
          wait(100 + random(30));
          typesend(inttostr(amount));
        end;
      end;
      
    
    begin
      setupsrl;
      activateclient;
      declareplayers;
      loginplayer;
      banker;
      getore;
      Findcactuscolor;
      tofurnace;
      findfurnace;
      choosebar;
    end.
    ok i got thise error eariler today but i cant figure it out can someone do it and then tell me what u did so i can fix it in the future

    btw the error is in the second case
    Last edited by JPHamlett; 05-26-2009 at 10:31 AM.

  2. #2
    Join Date
    Jan 2008
    Location
    California, US
    Posts
    2,765
    Mentioned
    0 Post(s)
    Quoted
    0 Post(s)

    Default

    I can't recreate it as I don't have as smither or anything, but it looks fine...
    SCAR Code:
    else Writeln('incorrect speeling srry');
    ->
    SCAR Code:
    else Writeln('Incorrect spelling, sorry.');

  3. #3
    Join Date
    Feb 2009
    Posts
    2,155
    Mentioned
    4 Post(s)
    Quoted
    42 Post(s)

    Default

    i think that you were looking at the wrong case it in the choosbar procedure

  4. #4
    Join Date
    Jan 2008
    Location
    California, US
    Posts
    2,765
    Mentioned
    0 Post(s)
    Quoted
    0 Post(s)

    Default

    Well then, that procedure seems perfectly fine except for this (however, it would not cause that error):
    SCAR Code:
    if findcolortolerance(x, y, barcolor, msx1, msy1, msx2, msy2, 15) then
        mmouse(x,y,3,3);
        if(isuptext(Lowercase(Players[CurrentPlayer].Strings[0]))) then
        begin
          mouse(x, y, 3, 3, false);
          wait(100 + random(20));
          chooseoption('X');
          wait(100 + random(30));
          typesend(inttostr(amount));
        end;
      end;
    This part specifically:
    SCAR Code:
    mmouse(x,y,3,3);
        if(isuptext(Lowercase(Players[CurrentPlayer].Strings[0]))) then
        begin
          mouse(x, y, 3, 3, false);
    Now first you move the mouse to the color with 3 randomness, then you check the uptext. If the uptext is found, you right click with another 3 randomness (not in the same place, and very fast). What you should have done is this
    SCAR Code:
    if findcolortolerance(x, y, barcolor, msx1, msy1, msx2, msy2, 15) then
        mmouse(x,y,3,3);
        if(isuptext(Lowercase(Players[CurrentPlayer].Strings[0]))) then
        begin
         GetMousePos(x, y);
          mouse(x, y, 0, 0, false);
          wait(100 + random(20));
          chooseoption('X');
          wait(100 + random(30));
          typesend(inttostr(amount));
        end;
      end;

  5. #5
    Join Date
    Oct 2007
    Location
    Denmark
    Posts
    409
    Mentioned
    0 Post(s)
    Quoted
    0 Post(s)

    Default

    It compiles?

  6. #6
    Join Date
    Feb 2009
    Posts
    2,155
    Mentioned
    4 Post(s)
    Quoted
    42 Post(s)

    Default

    yes it does

  7. #7
    Join Date
    May 2007
    Location
    UK
    Posts
    4,007
    Mentioned
    1 Post(s)
    Quoted
    12 Post(s)

    Default

    What, Doesnt it do?
    Put some debug around, and see what it doesnt do right.

    T~M

  8. #8
    Join Date
    Feb 2009
    Posts
    2,155
    Mentioned
    4 Post(s)
    Quoted
    42 Post(s)

    Default

    i tried it doenst even search for the bar it actomatically give the error it starts the procedure jsut gives me the error after it starts

  9. #9
    Join Date
    Feb 2007
    Posts
    3,616
    Mentioned
    0 Post(s)
    Quoted
    0 Post(s)

    Default

    The only reason it would be giving an out of range error on that line is if the current player is a number greater then the amount of players. So, do a writeln(inttostr(CurrentPlayer)); before casing it to see what the current player is. I ran the program with this as the main loop and it came out to 0 being the current player, and it didn't give me the error at that line:

    SCAR Code:
    begin
      setupsrl;
      activateclient;
      declareplayers;
      choosebar;
    end.

    So I am guessing that the current player is being incremented in one of the functions that I cancelled out and didn't call in the main loop. I was unable to run the whole thing since I don't have a runescape account to test with right now.


    Hope that fixes the problem.

    Edit: Maybe Login Player increments it? Idk I'm probably wrong. Haven't looked at the srl include in about a year...
    Last edited by JAD; 05-27-2009 at 11:51 AM.

  10. #10
    Join Date
    Jan 2008
    Location
    California, US
    Posts
    2,765
    Mentioned
    0 Post(s)
    Quoted
    0 Post(s)

    Default

    You are wrong, nextplayer increments it .

    And also, it is just because he did not call DeclarePlayers.

  11. #11
    Join Date
    Feb 2009
    Posts
    2,155
    Mentioned
    4 Post(s)
    Quoted
    42 Post(s)

    Default

    i did call declare players though

  12. #12
    Join Date
    Aug 2008
    Location
    Finland
    Posts
    2,851
    Mentioned
    3 Post(s)
    Quoted
    2 Post(s)

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •