Results 1 to 8 of 8

Thread: Runtime Error

  1. #1
    Join Date
    Feb 2006
    Posts
    3,044
    Mentioned
    4 Post(s)
    Quoted
    21 Post(s)

    Default Runtime Error

    Always When i try use this Lil Function
    It gives this...

    SCAR Code:
    [Runtime Error] : Out Of Range in line 1338 in script
    That Line Is :
    SCAR Code:
    if FindColorTolerance(x, y, colors[i], MSX1, MSY1, MSX2, MSY2, tolerance) or ScanMMAreaColorExactTolerance(x, y, MSX1, MSY1, MSX2, MSY2, colors[i], tolerance)then


    SCAR Code:
    function NearestObjMT(var cx, cy: Integer; Text:TStringArray; Colors: TIntegerArray; tolerance: Integer): Boolean;
    var
      x, y, a, c, i, x1, y1, x2, y2 : Integer;
    begin
     if (not(LoggedIn)) then
      Exit;
      if FindColorTolerance(x, y, colors[i], MSX1, MSY1, MSX2, MSY2, tolerance) or ScanMMAreaColorExactTolerance(x, y, MSX1, MSY1, MSX2, MSY2, colors[i], tolerance)then
      begin
        x1 := 245;
        y1 := 165;
        x2 := 277;
        y2 := 185;
        repeat
          if (not (Loggedin)) then
            break;
          a := a + 1;
          if (a = 1) then
            c := c + 1;
          if (a = 3) then
            c := c + 1;
          for i := 1 to c do
          begin
            if (a = 1) then
            begin
              x1 := x1 + 21;
              x2 := x2 + 21;
            end;
            if (a = 2) then
            begin
              y1 := y1 - 14;
              y2 := y2 - 14;
            end;
            if (a = 3) then
            begin
              x1 := x1 - 21;
              x2 := x2 - 21;
            end;
            if (a = 4) then
            begin
              y1 := y1 + 14;
              y2 := y2 + 14;
            end;
            if (x1 = 485) and (x2 = 517) then
              x2 := x2 - 2;
            if (y1 = 325) and (y2 = 345) then
              y2 := y2 - 7;
            if (x2 > 515) then
              Break;
            if FindColorTolerance(x, y, colors[i], MSX1, MSY1, MSX2, MSY2, tolerance) or ScanMMAreaColorExactTolerance(x, y, MSX1, MSY1, MSX2, MSY2, colors[i], tolerance)then
              begin
              MMouse(x, y, 0, 0)
              cx:=x;cy:=y;
              if IsUptextMultiCustom(Text) then
              begin
                Result := True;
                Break;
              end;
            end;
          end;
          if (a = 4) then
            a := 0;
        until (x2 > 515) or (Result = True);
      end;
    end;

  2. #2
    Join Date
    Feb 2006
    Location
    Amsterdam
    Posts
    13,692
    Mentioned
    146 Post(s)
    Quoted
    130 Post(s)

    Default

    How do you use it? Like that do you put in the function?
    You just take the first value of the array? (I = 0 at start, and you use Colors[i])
    So unless you only want to use colors, I suggest using
    for i := 0 to high(colors) do
    if findcolortolerance(colors[i]) then
    ...



    The best way to contact me is by email, which you can find on my website: http://wizzup.org
    I also get email notifications of private messages, though.

    Simba (on Twitter | Group on Villavu | Website | Stable/Unstable releases
    Documentation | Source | Simba Bug Tracker on Github and Villavu )


    My (Blog | Website)

  3. #3
    Join Date
    Feb 2006
    Posts
    3,044
    Mentioned
    4 Post(s)
    Quoted
    21 Post(s)

    Default

    Wizzup.. I didn't understand... I use this Function like in Openbank...

    SCAR Code:
    if NearestObjMT(x, y, ['se', 'oth', 'us','ank', 'Use ', 'nk'],
        [10463921,23243,6643], 20)

    Sorry :/


    ~Home

  4. #4
    Join Date
    Feb 2006
    Location
    Amsterdam
    Posts
    13,692
    Mentioned
    146 Post(s)
    Quoted
    130 Post(s)

    Default

    Well, basically.
    You put in an integer array. Called Colors.
    I think you know how arrays work.
    So Colors[0] would be 10463921
    Colors[1] Would be 23243
    and Colors[2] would be 664.

    The value you put in FindColorTolerance has to be an integer. so any value from Colors.
    The error you get is because you requested an index from the Color array which does not exist. (Out Of Range)

    Arrays are often used with For loops.

    SCAR Code:
    for i := low(colors) to high(colors) do
    begin // low(array) = minindex in array, high(array) is max index of array.
      if findcolortolerance(x, y, colors[i], x1, y1, x2, y2) then
      mmouse();
      wait()
      if isuptext() then
      begin
        getmousepos(x,y);
        mouse(x,y,0,0,true);
        break; // break out of the for loop. So it won't look for other colors when it has found it's target.
      end;
    end;



    The best way to contact me is by email, which you can find on my website: http://wizzup.org
    I also get email notifications of private messages, though.

    Simba (on Twitter | Group on Villavu | Website | Stable/Unstable releases
    Documentation | Source | Simba Bug Tracker on Github and Villavu )


    My (Blog | Website)

  5. #5
    Join Date
    Mar 2007
    Posts
    3,116
    Mentioned
    0 Post(s)
    Quoted
    2 Post(s)

    Default

    Why wouldn't getarraylength() work here? so like
    SCAR Code:
    for i := 0 to getarraylength(colors) do

  6. #6
    Join Date
    Feb 2006
    Location
    Amsterdam
    Posts
    13,692
    Mentioned
    146 Post(s)
    Quoted
    130 Post(s)

    Default

    Quote Originally Posted by Mylesmadness View Post
    Why wouldn't getarraylength() work here? so like
    SCAR Code:
    for i := 0 to getarraylength(colors) do
    That would be i := 0 to GetArrayLength - 1.

    Either GetArrayLength() - 1, Length() - 1 or High(). (not -1)



    The best way to contact me is by email, which you can find on my website: http://wizzup.org
    I also get email notifications of private messages, though.

    Simba (on Twitter | Group on Villavu | Website | Stable/Unstable releases
    Documentation | Source | Simba Bug Tracker on Github and Villavu )


    My (Blog | Website)

  7. #7
    Join Date
    Mar 2007
    Posts
    3,116
    Mentioned
    0 Post(s)
    Quoted
    2 Post(s)

    Default

    Length is strings though right?

  8. #8
    Join Date
    Feb 2006
    Location
    Amsterdam
    Posts
    13,692
    Mentioned
    146 Post(s)
    Quoted
    130 Post(s)

    Default

    Quote Originally Posted by Mylesmadness View Post
    Length is strings though right?
    A string is an array of char. Length and SetLength are for arrays too.



    The best way to contact me is by email, which you can find on my website: http://wizzup.org
    I also get email notifications of private messages, though.

    Simba (on Twitter | Group on Villavu | Website | Stable/Unstable releases
    Documentation | Source | Simba Bug Tracker on Github and Villavu )


    My (Blog | Website)

Thread Information

Users Browsing this Thread

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

Similar Threads

  1. [Runtime Error] : Exception: buffer error
    By GasMan in forum OSR Help
    Replies: 11
    Last Post: 05-13-2007, 02:07 PM
  2. Runtime Error
    By CamHart in forum OSR Help
    Replies: 2
    Last Post: 11-23-2006, 05:21 AM
  3. Runtime error
    By sk8ter in forum OSR Help
    Replies: 3
    Last Post: 10-30-2006, 01:55 PM

Posting Permissions

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