Results 1 to 5 of 5

Thread: Auto Beer Buyer

  1. #1
    Join Date
    Sep 2007
    Posts
    46
    Mentioned
    0 Post(s)
    Quoted
    0 Post(s)

    Default Auto Beer Buyer

    I'm making a program to buy beers at the bar in Faldor.

    I've been trying to get it to work, but there's some weird problem with the Mouse procedure. If I replace it with clickmouse it moves and clicks like it should. I have the feeling that I'm not understanding something...

    SCAR Code:
    program BeerBuyer;
    {.include SRL/SRL.scar}

    const
    typeOfBeer=0; //0 for asgarian ale, 1 for wizard's mind bomb, 2 for dwarven stout

    Function AskForBeer: Boolean;
    var
      x, y: integer;
    begin
      x:=0;
      if FindColorTolerance(x,y,1486254, 0, 0, 800, 540,15) then
      begin
        Writeln('1a');
        wait(random(100));
        Mouse(x,y,3,3,True);
        Writeln('1b');
        if FindColorTolerance(x,y,16711680, 0, 540, 800, 650,15) then
        begin
          Writeln('2');
          wait(50+random(50));
          Mouse(x,y,3,3,True);
          if FindColorTolerance(x,y,16711680, 0, 540, 800, 650,15) then
          begin
            Writeln('3');
            wait(50+random(50));
            Mouse(x,y,3,3,True);
            if FindColorTolerance(x,y,16711680, 0, 540, 800, 650,15) then
            begin
              Writeln('4');
              wait(50+random(50));
              Mouse(x,y,3,3,True);
              result:= True;
            end;
          end;
        end;
      end;
    end;
    Procedure BuyBeer;
    var
      x,y: integer;
    begin
      if (typeOfBeer = 0) then Mouse(483, 582, 10,2,True);
      if (typeOfBeer=1) then Mouse(483, 601, 10,2,True);
      if (typeOfBeer=2) then Mouse(483, 623, 10,2,True);
     
      if FindColorTolerance(x,y,16711680, 0, 540, 800, 650,15) then
      begin
        wait(50+random(50));
        Mouse(x,y,3,3,True);
      end;
    end;
     
    begin //mainloop
     repeat
       //if AskForBeer then BuyBeer;
       Writeln('0');
       AskForBeer;
     until(false)
    end.

    For some reason it prints 1a but not 1b, and then gets stuck.

    Help with this or with any other glaring problems you find would be greatly appreciated.

  2. #2
    Join Date
    Dec 2006
    Location
    Sweden
    Posts
    10,812
    Mentioned
    3 Post(s)
    Quoted
    16 Post(s)

    Default

    You must add SetupSRL;.

    Change your main loop to this:
    begin //mainloop
    SetupSRL;
    repeat
    //if AskForBeer then BuyBeer;
    Writeln('0');
    AskForBeer;
    until(false)
    end.

    and then Mouse will work


    Send SMS messages using Simba
    Please do not send me a PM asking for help; I will not be able to help you! Post in a relevant thread or make your own! And always remember to search first!

  3. #3
    Join Date
    Sep 2007
    Posts
    46
    Mentioned
    0 Post(s)
    Quoted
    0 Post(s)

    Default

    Thank you very much for your quick and helpful reply.

    When I finish the code so it works, I'll post it.

  4. #4
    Join Date
    Sep 2007
    Posts
    46
    Mentioned
    0 Post(s)
    Quoted
    0 Post(s)

    Default

    Here is an improved semi-working version of the Beer Buyer.

    SCAR Code:
    program BeerBuyer2;
    {.include SRL/SRL.scar}
    const
    typeOfBeer=1; //0 for asgarian ale, 1 for wizard's mind bomb, 2 for dwarven stout
    var
    failCount:integer;

    Function AskForBeer: Boolean;
    var
      x, y, MyMark1,i, MyMark2: integer;
    begin
      //click bar lady
      if FindObj(x,y,'ayl',9926794,10) then
      //if FindObj(x,y,'hop',791835,15) then
      begin
        wait(random(100));
        Mouse(x,y,3,3,True);

        //wait for her picture at bottom
        MarkTime(MyMark1);
        repeat
          wait(random(400));
          if (TimeFromMark(MyMark1)>5000) then
          begin
            failCount:=failCount+1;
            Exit;
          end;
        until (FindColorTolerance(x,y,1059709, 0, 340, 500, 500,25))

        //wait for and click blue text three times
        i:=0;
        while (i < 3) do
        begin
          i:= i + 1;
          MarkTime(MyMark2);
          repeat
            wait(random(400));
            if (TimeFromMark(MyMark2)>2000) then
            begin
              failCount:=failCount+2;
              Exit;
            end;
          until (FindColorTolerance(x,y,16711680, 0, 340, 500, 500,20))
          Mouse(x,y,3,3,True);
          MMouse(random(100),random(100),200,200);
        end;
        wait(random(1000)+200);
        result:= True;
      end else
        failCount:=failCount+2;
    end;

    Procedure BuyBeer;
    var
      x,y,MyMark3: integer;
    begin
      if (typeOfBeer=0) then Mouse(250, 388, 50,2,True);
      if (typeOfBeer=1) then Mouse(250, 406, 50,2,True);
      if (typeOfBeer=2) then Mouse(250, 430, 50,2,True);
     
      MarkTime(MyMark3);
      repeat
        wait(random(400));
        if (TimeFromMark(MyMark3)>2000) then
          begin
            failCount:=failCount+2;
            Exit;
          end;
      until (FindColorTolerance(x,y,16711680, 0, 340, 500, 500,20))
        Mouse(x,y,3,3,True);
        failCount:=0;
    end;
     
    begin //mainloop
     SetupSRL;
     ClearDebug;
     failCount:=0;
     repeat
       MMouse(random(100),random(100),200,200);
       wait(random(200));
       if AskForBeer then BuyBeer;
     until(failCount>40)
    end.

    What can I do to improve it?

    Here's a more specific question that I've been wondering:
    Is there a shortcut for 'a=a+1' in this programming language? I know that every other programming language I have learned so far has had some way to do it like 'a+=1', for example.

    Edit: Oh i remembered something. How do you print the value of a variable? I tried writeln(x) but that does not work.

  5. #5
    Join Date
    Mar 2008
    Posts
    11
    Mentioned
    0 Post(s)
    Quoted
    0 Post(s)

    Default

    Lol completely pointless but it looks fun, hope you get it working

Thread Information

Users Browsing this Thread

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

Similar Threads

  1. [SRL4]Beer Buyer
    By Dudenow12 in forum RS3 Outdated / Broken Scripts
    Replies: 14
    Last Post: 03-25-2008, 07:38 PM
  2. Need Auto Buyer
    By anaujiram in forum RS3 Outdated / Broken Scripts
    Replies: 1
    Last Post: 07-13-2007, 05:15 AM
  3. Auto buyer
    By rufuffel in forum RS3 Outdated / Broken Scripts
    Replies: 2
    Last Post: 05-18-2007, 09:04 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
  •