Results 1 to 14 of 14

Thread: "for..to..do" Help.

  1. #1
    Join Date
    May 2007
    Location
    England
    Posts
    4,140
    Mentioned
    11 Post(s)
    Quoted
    266 Post(s)

    Default "for..to..do" Help.

    Right, I'm trying to update my Dummy Hitter, because it's pretty poor at the moment I'll admit. I'm adding an uptext check, and an array for colours. This is what I've got so far. The lines with loads of /s are lines I've just put in to help myself debugging it.
    SCAR Code:
    program DummyHitter;
    {.include SRL/SRL.scar}

    var
      I, X, Y, XX, YY : Integer;
      Colour : TIntegerArray;

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

      Players[0].Name := '';
      Players[0].Pass := '';
      Players[0].Nick := '';
      Players[0].Active := True;
     
      {Players[1].Name := '';
      Players[1].Pass := '';
      Players[1].Nick := '';
      Players[1].Active := True;

      Players[2].Name := '';
      Players[2].Pass := '';
      Players[2].Nick := '';
      Players[2].Active := True;
     
      Players[3].Name := '';
      Players[3].Pass := '';
      Players[3].Nick := '';
      Players[3].Active := True;
     
      Players[4].Name := '';
      Players[4].Pass := '';
      Players[4].Nick := '';
      Players[4].Active := True; }

      end;

    procedure AntiBan;
    begin
      if not LoggedIn then
      begin
        Exit;
        Players[CurrentPlayer].Active := False;
      end;
      case Random(150) of
        0: RandomRClick;
        1: BoredHuman;
        2: HoverSkill('Attack', False);
      end;
    end;

    procedure AntiRandoms;
    begin
      if not LoggedIn then
      begin
        Exit;
        Players[CurrentPlayer].Active := False;
      end;
      FindNormalRandoms;
      if FindFight then
      RunAway('W', True, 1, 5000 + Random(2500));
      AntiBan;
    end;

    procedure LoadColours;
    begin
      Colour[0]:= 6849433;
      Colour[1]:= 7047070;
      Colour[2]:= 10139599;
      Colour[3]:= 8759236;
      Colour[4]:= 7771308;
      Colour[5]:= 8956871;
    end;

    procedure DummyHit;
    begin
      if not LoggedIn then
      begin
        Exit;
        Players[CurrentPlayer].Active := False;
      end;
      if FindSymbol(XX, YY, 'training dummy') then
      begin
        WriteLn('Found symbol'); ////////////////////
        MouseFlag(XX-10, YY, 5, 5, 1);
        Wait(500 + Random(250));
        ChatsOff;
      end else
        WriteLn('No dummy symbol');  //////////////////
      repeat
        AntiRandoms;
        for I:= 0 to 5 do
        if FindColorSpiralTolerance(x, y, Colour[i], MSX1, MSY1, MSX2, MSY2, 15) then
        begin
          AntiRandoms;
          WriteLn('Found dummy colour');//////////////////
          if IsUpText('ummy') then
          begin
            WriteLn('Found uptext');
            Mouse(x, y,5,5,True);
            Wait(1250 + Random(500));
          end else
          WriteLn('No uptext');   //////////////////
        end else
        WriteLn('No dummy colour');/////////////////
      until     (IsChatBoxTextAnyLine('nothing more you can learn', clBlack)) or
        not(FindSymbol(XX, YY, 'training dummy')) or
        not(FindColorSpiralTolerance(x, y, Colour[i], MSX1, MSY1, MSX2, MSY2, 15));
      Logout;
      Players[CurrentPlayer].Active := False;
    end;

    begin
      SetupSRL;
      ActivateClient;
      DeclarePlayers;
      LoginPlayer;
      repeat
        DummyHit;
        NextPlayer(False);
      until(AllPlayersInactive)
    end.
    This is what I got from the debug box
    Code:
    Successfully compiled (4488 ms)
    SRL Compiled in 62 msec
    ********
    Creating the NickTPA.
    Found symbol
    [Runtime Error] : Out Of Range in line 95 in script D:\Program Files\SCAR\SCAR 3.15\Scripts\My Scripts\Dummy Hitter\Dummy Hitter V1.1.scar
    Line 95 is
    SCAR Code:
    ntiRandoms;
        for I:= 0 to 5 do
        if FindColorSpiralTolerance(x, y, Colour[i], MSX1, MSY1, MSX2, MSY2, 15) //THIS LINE
    then
        begin
          AntiRandoms;
    I assume it's something to do with the "for..to..do" part, but meh, I might be wrong.

    Any help is appreciated.
    Thanks,
    Richard
    <3

    Quote Originally Posted by Eminem
    I don't care if you're black, white, straight, bisexual, gay, lesbian, short, tall, fat, skinny, rich or poor. If you're nice to me, I'll be nice to you. Simple as that.

  2. #2
    Join Date
    Oct 2007
    Location
    #srl
    Posts
    6,102
    Mentioned
    39 Post(s)
    Quoted
    62 Post(s)

    Default

    try this:
    SCAR Code:
    for i := 0 to High(Colour) do

    Also, include the colours in the same procedure they are used in.

    So put :
    SCAR Code:
    Colour := [6849433, 7047070, 10139599, 8759236, 7771308, 8956871];
    right above the for..to..do line.
    Last edited by NCDS; 05-06-2009 at 04:02 AM.

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

    Default

    umm.. ok im not 100% sure this correct not even 50% sure this correct but..
    Dont you have to do if True/False

    T~M

  4. #4
    Join Date
    May 2007
    Location
    England
    Posts
    4,140
    Mentioned
    11 Post(s)
    Quoted
    266 Post(s)

    Default

    Quote Originally Posted by NCDS View Post
    try this:
    SCAR Code:
    for i := 0 to High(Colour) do

    Also, include the colours in the same procedure they are used in.

    So put :
    SCAR Code:
    Colour := [6849433, 7047070, 10139599, 8759236, 7771308, 8956871];
    right above the for..to..do line.
    Thanks, I'll try that now.

    Quote Originally Posted by The Man View Post
    umm.. ok im not 100% sure this correct not even 50% sure this correct but..
    Dont you have to do if True/False

    T~M
    Don't think so...

    Richard.
    <3

    Quote Originally Posted by Eminem
    I don't care if you're black, white, straight, bisexual, gay, lesbian, short, tall, fat, skinny, rich or poor. If you're nice to me, I'll be nice to you. Simple as that.

  5. #5
    Join Date
    Oct 2007
    Location
    #srl
    Posts
    6,102
    Mentioned
    39 Post(s)
    Quoted
    62 Post(s)

    Default

    also,
    SCAR Code:
    procedure DummyHit;
    begin
      if not LoggedIn then
      begin
        Exit;
        Players[CurrentPlayer].Active := False;
      end;
    wont work.

    That will Exit the procedure before setting NextPlayer(False);

    Just put the 'Exit;' after the 'Player[CurrentPlayer].Active := False;'

  6. #6
    Join Date
    May 2007
    Location
    England
    Posts
    4,140
    Mentioned
    11 Post(s)
    Quoted
    266 Post(s)

    Default

    Oh yeah, it's silly little mistakes like that which really annoy me.

    Thanks,
    Richard
    <3

    Quote Originally Posted by Eminem
    I don't care if you're black, white, straight, bisexual, gay, lesbian, short, tall, fat, skinny, rich or poor. If you're nice to me, I'll be nice to you. Simple as that.

  7. #7
    Join Date
    Sep 2006
    Location
    Canada
    Posts
    1,124
    Mentioned
    0 Post(s)
    Quoted
    5 Post(s)

    Default

    When a for loop ends it will be one higher then what you put it to.

    Code:
    program New;
    var
      i: integer;
    
    
    begin
    for i:= 0 to 3 do
    writeln(i);
    writeln(i);
    end.
    Will output

    Code:
    0
    1
    2
    3
    4
    So if you still have out-of-range errors after NCDS helping you then this will be your problem.

    Though your problem is different, you never actually declared your array! You forgot to call your LoadColor; procedure.

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

    Default

    Quote Originally Posted by Capricorn View Post
    When a for loop ends it will be one higher then what you put it to.

    Code:
    program New;
    var
      i: integer;
    
    
    begin
    for i:= 0 to 3 do
    writeln(i);
    writeln(i);
    end.
    Will output

    Code:
    0
    1
    2
    3
    4
    So if you still have out-of-range errors after NCDS helping you then this will be your problem.

    Though your problem is different, you never actually declared your array! You forgot to call your LoadColor; procedure.
    i dont think it does actually, i think your getting confused with that it gives out 4 cause 0 to 3 will give 0,1,2,3 which is 4 i'm not sure, as im crap at scripting but you might be getting confused

    T~M

  9. #9
    Join Date
    Feb 2007
    Location
    Access Violation at 0x00000000
    Posts
    2,865
    Mentioned
    3 Post(s)
    Quoted
    18 Post(s)

    Default

    Quote Originally Posted by The Man View Post
    i dont think it does actually, i think your getting confused with that it gives out 4 cause 0 to 3 will give 0,1,2,3 which is 4 i'm not sure, as im crap at scripting but you might be getting confused

    T~M
    Yeh I think the guy's confused with the "0" also counting.
    Ce ne sont que des gueux


  10. #10
    Join Date
    May 2007
    Location
    England
    Posts
    4,140
    Mentioned
    11 Post(s)
    Quoted
    266 Post(s)

    Default

    Thanks guys, I've sorted it all out and am just about to update my thread.

    Thanks again,
    Richard
    <3

    Quote Originally Posted by Eminem
    I don't care if you're black, white, straight, bisexual, gay, lesbian, short, tall, fat, skinny, rich or poor. If you're nice to me, I'll be nice to you. Simple as that.

  11. #11
    Join Date
    Sep 2006
    Location
    Canada
    Posts
    1,124
    Mentioned
    0 Post(s)
    Quoted
    5 Post(s)

    Default

    No I am not confused with the 0 counting. The example code I used says from 0 to 3. Then how would the output ever get to 4 if it is only supposed to goto 3? If you ever call a integer inside of a array after a for loop has ended it will be one higher then the high of the high of the array.

    For example
    Code:
    program New;
    var
      i: array of integer;
      z: integer;
      
    begin
    i := [0, 1];
    for z := 0 to high(i) do
      begin
        writeln(i[z]);
        writeln(z);
      end;
      writeln(z);
      writeln(i[z]);
    end.
    Will give a out of range error because z is at 2 while there are only 2 value in the array! It has nothing to do with zero being counted. 0 has a value of 0 and represents 0, and so on. How can 3 have a value of 4? How can three represent four? It can't. And it all comes down to how the for loop looks at the condition.

    I don't know, this type of problem gave me troubles on some of my first scripts because if I have searched through a array and tried to do some sort of procedure or function and would end up getting out of range errors so I figured I would mention it. So its best to do array stuff inside of a for loop, and to stick to doing it inside of it so you don't end up with out of range problems down the road.

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

    Default

    Quote Originally Posted by Capricorn View Post
    No I am not confused with the 0 counting. The example code I used says from 0 to 3. Then how would the output ever get to 4 if it is only supposed to goto 3? If you ever call a integer inside of a array after a for loop has ended it will be one higher then the high of the high of the array.

    For example
    Code:
    program New;
    var
      i: array of integer;
      z: integer;
      
    begin
    i := [0, 1];
    for z := 0 to high(i) do
      begin
        writeln(i[z]);
        writeln(z);
      end;
      writeln(z);
      writeln(i[z]);
    end.
    Will give a out of range error because z is at 2 while there are only 2 value in the array! It has nothing to do with zero being counted. 0 has a value of 0 and represents 0, and so on. How can 3 have a value of 4? How can three represent four? It can't. And it all comes down to how the for loop looks at the condition.

    I don't know, this type of problem gave me troubles on some of my first scripts because if I have searched through a array and tried to do some sort of procedure or function and would end up getting out of range errors so I figured I would mention it. So its best to do array stuff inside of a for loop, and to stick to doing it inside of it so you don't end up with out of range problems down the road.
    lol ok, cant be assed to argue or type very long sentences like this for absolutely no reason at all.... CBA Life

    Hope this helps

    T~M

  13. #13
    Join Date
    Feb 2007
    Location
    Access Violation at 0x00000000
    Posts
    2,865
    Mentioned
    3 Post(s)
    Quoted
    18 Post(s)

    Default

    Code:
    Successfully compiled (47 ms)
    0
    1
    2
    3
    Successfully executed
    That's what your example gives.
    Ce ne sont que des gueux


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

    Default

    Quote Originally Posted by Floor66 View Post
    Code:
    Successfully compiled (47 ms)
    0
    1
    2
    3
    Successfully executed
    That's what your example gives. - . -
    HAHA pwned!!!!!!! lemme just edit the end.... DONE!

    T~m

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
  •