Results 1 to 13 of 13

Thread: Help with arrays.

  1. #1
    Join Date
    Apr 2009
    Location
    California!
    Posts
    280
    Mentioned
    0 Post(s)
    Quoted
    0 Post(s)

    Default Help with arrays.

    Hey, everyone it's me again!
    I was wondering if you guys could help me with making arrays "Random"
    Like in the script below. I want it to check a random Inv Spot, And Click on it if it's there. And I would like it to be random.
    Take a look at this procedure in my Stringer, and tell me if you can help
    All help is appreciated and will Rep++
    Thanks!

    SCAR Code:
    procedure ViperStringing;
    var
      InvCheck: array [1..14] of Integer;
      i: Integer;
    begin
      begin
        MarkTime(LoadTime);
        Writeln('Viper Stringing!');
        FindDTM(LongUDTM, x, y, mix1, miy1, mix2, miy2);
        begin
        for i:= Random(1 To 14)do //Here.
          0: if(ExistsItem(inttostr(InvCheck[i])) = True)then
          begin
            wait(200+random(500));
            MouseItem((inttostr(InvCheck[i])), True);
          end else
          Writeln('No Longbows found, Exiting');
        end;//To Here. (Will edit the random array clicking on the bowstring after)
        Mouse(x, y, 5, 5, True);
        wait(200+random(200));
        FindDTM(BowstringDTM, x, y, mix1, miy1, mix2, miy2);
        Mouse(x, y, 5, 5, True);
        wait(300+random(200));
        Mouse(mccx, mccy, 5, 5, false);
        wait(200+random(200));
        ChooseOption('All');
        repeat
        Antiban;
        ClearDebug;
        Proggy;
        Writeln('Loads Till Sleep: '+IntToStr(SleepIn - SleepLoads)+'.');
        case Random(6) of
          0: Antiban;
          1: Wait(3000+random(2000));
          2: Wait(8000+random(2000));
          3: Wait(3000+random(1000));
          4: Antiban;
          5: Wait(5000+random(1000));
        end;
        RandomsCheck;
        until (FindDTMInv(LongbowDTM, 14) = True) or (TimeFromMark(LoadTime) > 60000);
        begin
          writeln('Done.');
        end;
      end;
    end;
    ~Penguin
    Semi-active
    http://i44.tinypic.com/33vk9aq.jpg
    SELL AUTOED GOODS AT MID-MAX! DON'T LET PRICES FALL AND GIVE US LESS PROFIT. (Put this in your sig)

  2. #2
    Join Date
    Sep 2006
    Location
    New Jersey, USA
    Posts
    5,347
    Mentioned
    1 Post(s)
    Quoted
    3 Post(s)

    Default

    SCAR Code:
    var
      checked: Array [1..14] of Boolean;
      curr: Integer;

    for i:= 1 to 14 do
    begin
      do
        curr := random(14) + 1; //Chooses a random spot (from 1 to 14)
      while(checked[curr]) //If that spot has already been checked, generates a new spot

      checked[curr] := true; //So it won't check this spot again
      if(ExistsItem(inttostr(InvCheck[curr])))then
      begin
        wait(200+random(500));
        MouseItem((inttostr(InvCheck[curr])), True);
      end
        else
          writeln('No longbow in this spot..');
    end;

    Something like that?
    Interested in C# and Electrical Engineering? This might interest you.

  3. #3
    Join Date
    Apr 2009
    Location
    California!
    Posts
    280
    Mentioned
    0 Post(s)
    Quoted
    0 Post(s)

    Default

    Ohh!! I'll be testing it out. Thanks!

    Edit: This is not working, tried editing it but no luck. It doesen't make much sense, since Invcheck is not a variable.
    Hope this helps.

    Here's what I got so far.
    SCAR Code:
    procedure ViperStringing;
    var
      Checked: Array [1..14] of Integer;
      C: Integer;

    begin
    for C:= 1 to 14 do
    begin
      do C := random(14) + 1; //Chooses a random spot (from 1 to 14)
      while(Checked[C]) //If that spot has already been checked, generates a new spot

      Checked[C] := true; //So it won't check this spot again
      if(ExistsItem(inttostr(Checked[C])))then
      begin
        wait(200+random(500));
        MouseItem((inttostr(Checked[C])), True);
      end
        else
          writeln('No longbow in this spot..');
       end
        Mouse(x, y, 5, 5, True);
        wait(200+random(200));
        FindDTM(BowstringDTM, x, y, mix1, miy1, mix2, miy2);
        Mouse(x, y, 5, 5, True);
        wait(300+random(200));
        Mouse(mccx, mccy, 5, 5, false);
        wait(200+random(200));
        ChooseOption('All');
        repeat
        Antiban;
        ClearDebug;
        Proggy;
        Writeln('Loads Till Sleep: '+IntToStr(SleepIn - SleepLoads)+'.');
        case Random(6) of
          0: Antiban;
          1: Wait(3000+random(2000));
          2: Wait(8000+random(2000));
          3: Wait(3000+random(1000));
          4: Antiban;
          5: Wait(5000+random(1000));
        end;
        RandomsCheck;
        until (FindDTMInv(LongbowDTM, 14) = True) or (TimeFromMark(LoadTime) > 60000);
        begin
          writeln('Done.');
        end;
      end;
    end;

    Error at Line 699.

    Line 699 is
    SCAR Code:
    do C := random(14) + 1; //Chooses a random spot (from 1 to 14)
    ~Penguin
    Semi-active
    http://i44.tinypic.com/33vk9aq.jpg
    SELL AUTOED GOODS AT MID-MAX! DON'T LET PRICES FALL AND GIVE US LESS PROFIT. (Put this in your sig)

  4. #4
    Join Date
    Dec 2006
    Location
    Canada, BC
    Posts
    728
    Mentioned
    0 Post(s)
    Quoted
    0 Post(s)

    Default

    remove the "do" and make it just
    SCAR Code:
    C := random(14) + 1; //Chooses a random spot (from 1 to 14)
    i donno why you would put a random "do" there XD
    Lance. Da. Pants.

  5. #5
    Join Date
    Jan 2007
    Posts
    8,876
    Mentioned
    123 Post(s)
    Quoted
    327 Post(s)

    Default

    Quote Originally Posted by lancerawks View Post
    remove the "do" and make it just
    i donno why you would put a random "do" there XD
    It was a do ... while loop

    That loop would just keep on going until you stop it, what if every Checked[curr] is false?

  6. #6
    Join Date
    Mar 2007
    Posts
    3,042
    Mentioned
    1 Post(s)
    Quoted
    14 Post(s)

    Default

    Yes, but SCAR's do..while loop is repeat..until, isn't it?
    :-)

  7. #7
    Join Date
    Aug 2007
    Location
    in a random little world
    Posts
    5,778
    Mentioned
    0 Post(s)
    Quoted
    7 Post(s)

  8. #8
    Join Date
    Mar 2007
    Posts
    3,042
    Mentioned
    1 Post(s)
    Quoted
    14 Post(s)

    Default

    So SCAR handles do..while also, then?

    EDIT: If so, I guess I learned something new today, but it seems pointless to have both.
    :-)

  9. #9
    Join Date
    Oct 2006
    Location
    ithurtsithurtsithurtsithurts
    Posts
    2,930
    Mentioned
    7 Post(s)
    Quoted
    135 Post(s)

    Default

    Quote Originally Posted by Method View Post
    So SCAR handles do..while also, then?

    EDIT: If so, I guess I learned something new today, but it seems pointless to have both.
    I don't think it supports do..while. I just tried and it gave me an error.

  10. #10
    Join Date
    Jan 2007
    Posts
    8,876
    Mentioned
    123 Post(s)
    Quoted
    327 Post(s)

    Default

    Quote Originally Posted by senrath View Post
    I don't think it supports do..while. I just tried and it gave me an error.
    That is correct, do..while does not work for scar, but repeat until do work :P

  11. #11
    Join Date
    Mar 2008
    Location
    ::1
    Posts
    915
    Mentioned
    0 Post(s)
    Quoted
    1 Post(s)

    Default

    Quote Originally Posted by Zyt3x View Post
    That is correct, do..while does not work for scar, but repeat until do work :P
    Does work you mean. Right?

    Records and Types Save Code (and make you look better)
    Quote Originally Posted by Wizzup? View Post
    Is it possible to make Runescape a 2D game with this?... That would greatly simplify... Just about anything.

  12. #12
    Join Date
    Jan 2008
    Location
    Ontario, Canada
    Posts
    7,805
    Mentioned
    5 Post(s)
    Quoted
    3 Post(s)

    Default

    Penguin is this what you wanted:

    SCAR Code:
    t: TPointArray;
    ...
      t := ItemCoords();
      c := Random(Length(t));
      Mouse(t[c].x, t[c].y, 4, 4, True);

    That kind of thing?
    Writing an SRL Member Application | [Updated] Pascal Scripting Statements
    My GitHub

    Progress Report:
    13:46 <@BenLand100> <SourceCode> @BenLand100: what you have just said shows you 
                        have serious physchological problems
    13:46 <@BenLand100> HE GETS IT!
    13:46 <@BenLand100> HE FINALLY GETS IT!!!!1

  13. #13
    Join Date
    Sep 2006
    Location
    New Jersey, USA
    Posts
    5,347
    Mentioned
    1 Post(s)
    Quoted
    3 Post(s)

    Default

    *sigh*

    Yes, the do while was wrong. It should be repeat-until. (SCAR's do-while works backwards to my thought process =/ While (true) do)

    The difference between a repeat-until and a do-while is when the condition is checked. While loops are checked at the top of the loop, repeat loops at the bottom. Thus, a repeat loop will always run through the code at least once, whereas a while loop will not run the code if the condition is false.


    That loop would just keep on going until you stop it, what if every Checked[curr] is false?
    They will never all be false at this point in the code, because it is enclosed in a for loop that only iterates 14 times.



    SCAR Code:
    procedure ViperStringing;
    var
      Checked: Array [1..14] of Integer;
      i, C: Integer;

    begin
    for i:= 1 to 14 do
    begin
      repeat
        C := random(14) + 1; //Chooses a random spot (from 1 to 14)
      until(Checked[C] = 0) //If that spot has already been checked, generates a new spot

      Checked[C] := 1; //So it won't check this spot again
      if(ExistsItem(inttostr(C)))then
      begin
        wait(200+random(500));
        MouseItem((inttostr(C)), True);
      end
        else
          writeln('No longbow in this spot..');
     end
        Mouse(x, y, 5, 5, True);
        wait(200+random(200));
        FindDTM(BowstringDTM, x, y, mix1, miy1, mix2, miy2);
        Mouse(x, y, 5, 5, True);
        wait(300+random(200));
        Mouse(mccx, mccy, 5, 5, false);
        wait(200+random(200));
        ChooseOption('All');
        repeat
        Antiban;
        ClearDebug;
        Proggy;
        Writeln('Loads Till Sleep: '+IntToStr(SleepIn - SleepLoads)+'.');
        case Random(6) of
          0: Antiban;
          1: Wait(3000+random(2000));
          2: Wait(8000+random(2000));
          3: Wait(3000+random(1000));
          4: Antiban;
          5: Wait(5000+random(1000));
        end;
        RandomsCheck;
        until (FindDTMInv(LongbowDTM, 14) = True) or (TimeFromMark(LoadTime) > 60000);
        begin
          writeln('Done.');
        end;
      end;
    end;
    Interested in C# and Electrical Engineering? This might interest you.

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
  •