Results 1 to 8 of 8

Thread: Problem with script - skips a procedure?

  1. #1
    Join Date
    May 2013
    Location
    The Netherlands
    Posts
    12
    Mentioned
    0 Post(s)
    Quoted
    3 Post(s)

    Question Problem with script - skips a procedure?

    I've only discovered simba about a week ago, started botting and wanted to start making my own scripts. So I read some guides and started making my own script two days ago. It's really really basic, has no antibans or antirandoms nothing like that.

    My script seems to work, but when it starts his second run through the main loop he just skips the first procedure wich is banking;

    ( the script should withdraw supplies from the pest control bank, then make prayer potions and bank them - repeat )

    My main loop:

    Simba Code:
    var
      t : Integer;
       
    begin
      Setup;
      repeat
        Banking;
        ClickPot;
        ClickHerb;
        Mixing;
        MarkTime(t);
        while ExistsItem(28) do
          begin
            wait(100);
            if TimeFromMark(t) > 20000 then
                begin
                  writeln('Took to much time to complete inv. Breaking out of loop');
                  Break;
                end;
          end;
        writeln('We made potions!');
      until not (LoggedIn);
      Terminatescript;
    end.

    My banking procedure:

    Simba Code:
    procedure Banking;
      var
        I : Integer;

    begin
      MakeObj('bank', 5599869, 2, 0.22, 0.53, [ 'ank', 'ank', 'ooth'], ['ank']);

      if (ExistsItem(27)) then
        begin
        Writeln('Starting to make potions');
        end else

        begin
        SmartColors('bank');
        wait(400 + random(100));
        if (BankScreen = True) then
          begin
            DepositAll;
            wait(150 + random(63));
            Withdraw(0, 0, 14);
            wait(150 + random(67));
            Withdraw(1, 0, 0);
            wait(100 + random(95));
            CloseBank;
          end else
            I := 1;
            repeat
              SmartColors('bank');
              I := (I + 1);
              wait(1000 + random(224));
            until (I = 5);
        end;

    end;

    So what happens is, the script succesfully logs in, opens the bank and withdraws supplies from 1st and 2nd bank slot, it closes the bank and makes the pots. Than when it should bank again, it doesn't and skips to procedure ClickHerb; OR it opens the bank and than skips to procedure Clickpot/Clickherb.

    I'm not sure what to do, any help or tips would be greatly appreciated
    Last edited by Herbs N Tea; 05-23-2013 at 09:51 AM. Reason: wrong code tags

  2. #2
    Join Date
    Mar 2006
    Location
    Belgium
    Posts
    3,564
    Mentioned
    111 Post(s)
    Quoted
    1475 Post(s)

    Default

    After you've done a load, are there 27 items in your inventory then?

    in your banking procedure u have this line:
    Simba Code:
    if (ExistsItem(27)) then
        begin
        Writeln('Starting to make potions');
    This won't bank if an item exists on the 27th slot.
    It will skip the whole banking procedure and move on with the mainloop.

    Creds to DannyRS for this wonderful sig!

  3. #3
    Join Date
    May 2013
    Location
    The Netherlands
    Posts
    12
    Mentioned
    0 Post(s)
    Quoted
    3 Post(s)

    Default

    Quote Originally Posted by Sjoe View Post
    After you've done a load, are there 27 items in your inventory then?

    in your banking procedure u have this line:
    Simba Code:
    if (ExistsItem(27)) then
        begin
        Writeln('Starting to make potions');
    This won't bank if an item exists on the 27th slot.
    It will skip the whole banking procedure and move on with the mainloop.
    No, after doing a load theres 14 items in my inventory. I could've made it check slot 15 but I gues with this line it will still look for supplies if you've allready made for example halve the inventory.

    Thanks alot for taking a look tho


    /edit, I just noticed checking item 27 is really stupid, since this slot will only be empty when the inv is almost done >.<
    Last edited by Herbs N Tea; 05-23-2013 at 09:57 AM.

  4. #4
    Join Date
    Mar 2006
    Location
    Belgium
    Posts
    3,564
    Mentioned
    111 Post(s)
    Quoted
    1475 Post(s)

    Default

    When I'm in doubt I always make debug lines, to see where the script is.
    Like u did for if ExistsItem(27) then writeln(' starting to make potions') , do this variously for other places.
    Debugging is a powerful scripting tool to use!

    also:
    Simba Code:
    while ExistsItem(28) do // shouldnt this be ExistItem(15)?
    begin
       wait(100);
       if TimeFromMark(t) > 20000 then
       begin
          writeln('Took to much time to complete inv. Breaking out of loop');
          Break;
       end;
    end;

    Creds to DannyRS for this wonderful sig!

  5. #5
    Join Date
    Jun 2007
    Location
    The land of the long white cloud.
    Posts
    3,702
    Mentioned
    261 Post(s)
    Quoted
    2006 Post(s)

    Default

    Quote Originally Posted by Herbs N Tea View Post
    No, after doing a load theres 14 items in my inventory. I could've made it check slot 15 but I gues with this line it will still look for supplies if you've allready made for example halve the inventory.

    Thanks alot for taking a look tho


    /edit, I just noticed checking item 27 is really stupid, since this slot will only be empty when the inv is almost done >.<
    Ok without seeing the rest of your script I can't be sure, but I think I may know your problem.

    Simba Code:
    procedure Banking;
      var
        I : Integer;

    begin     // Ok let's say MakeObj failed to find the bank
      MakeObj('bank', 5599869, 2, 0.22, 0.53, [ 'ank', 'ank', 'ooth'], ['ank']);

      if (ExistsItem(27)) then  //after you make pots inv slot 27 will be empty
        begin
        Writeln('Starting to make potions'); //therefore it will skip this
        end else

        begin  // and begin this instead
        SmartColors('bank');
        wait(400 + random(100));
        if (BankScreen = True) then  //the bank screen wont be open as MakObj failed
          begin      //so it skips this
            DepositAll;
            wait(150 + random(63));
            Withdraw(0, 0, 14);
            wait(150 + random(67));
            Withdraw(1, 0, 0);
            wait(100 + random(95));
            CloseBank;
          end else
            I := 1;  // and starts down here
            repeat
              SmartColors('bank');
              I := (I + 1);
              wait(1000 + random(224));
            until (I = 5);// not sure what this loop is. Just repeats a 1 sec wait?
        end;
    end; // and the Banking procedure has ended an all we did was wait 4 seconds :/


    So, maybe you could do something like this:

    Simba Code:
    procedure Banking;
      var
        I, bankTime: Integer;

    begin
      if (InvCount > 0) then // if stuff in inv then look for the bank!
      begin
        markTime(bankTime);
        repeat
          SmartColors('bank'); // I assume this is a status painted on smart
          MakeObj('bank', 5599869, 2, 0.22, 0.53, [ 'ank', 'ank', 'ooth'], ['ank']);
          wait(400 + random(100));
        until bankScreen or (timeFromMark(bankTime) > 20000);
        //now it will repeat MakeObj until it finds the bank screen or times out.

        if BankScreen then
        begin
          writeln('found bank')
          DepositAll;
          wait(150 + random(63));
          Withdraw(0, 0, 14);
          wait(150 + random(67));
          Withdraw(1, 0, 0);
          wait(100 + random(95));
          CloseBank;
        end else
          writeLn('failed to find bank'); { If this displays in the debug box }
      end;                                { Then you know MakeObj failed to find the bank }
    end;                                  { after 20 seconds }

  6. #6
    Join Date
    May 2013
    Location
    The Netherlands
    Posts
    12
    Mentioned
    0 Post(s)
    Quoted
    3 Post(s)

    Default

    Quote Originally Posted by Sjoe View Post
    When I'm in doubt I always make debug lines, to see where the script is.
    Like u did for if ExistsItem(27) then writeln(' starting to make potions') , do this variously for other places.
    Debugging is a powerful scripting tool to use!

    also:
    Simba Code:
    while ExistsItem(28) do // shouldnt this be ExistItem(15)?
    begin
       wait(100);
       if TimeFromMark(t) > 20000 then
       begin
          writeln('Took to much time to complete inv. Breaking out of loop');
          Break;
       end;
    end;
    Thanks for the tip, I didn't even think about adding more lines for debugging :P (I only started this two days ago)

    And it shouldn't be 15, because I want it to keep waiting untill theres no item in slot 28


    Quote Originally Posted by The Mayor View Post
    Ok without seeing the rest of your script I can't be sure, but I think I may know your problem.

    Simba Code:
    procedure Banking;
      var
        I : Integer;

    begin     // Ok let's say MakeObj failed to find the bank
      MakeObj('bank', 5599869, 2, 0.22, 0.53, [ 'ank', 'ank', 'ooth'], ['ank']);

      if (ExistsItem(27)) then  //after you make pots inv slot 27 will be empty
        begin
        Writeln('Starting to make potions'); //therefore it will skip this
        end else

        begin  // and begin this instead
        SmartColors('bank');
        wait(400 + random(100));
        if (BankScreen = True) then  //the bank screen wont be open as MakObj failed
          begin      //so it skips this
            DepositAll;
            wait(150 + random(63));
            Withdraw(0, 0, 14);
            wait(150 + random(67));
            Withdraw(1, 0, 0);
            wait(100 + random(95));
            CloseBank;
          end else
            I := 1;  // and starts down here
            repeat
              SmartColors('bank');
              I := (I + 1);
              wait(1000 + random(224));
            until (I = 5);// not sure what this loop is. Just repeats a 1 sec wait?
        end;
    end; // and the Banking procedure has ended an all we did was wait 4 seconds :/


    So, maybe you could do something like this:

    Simba Code:
    procedure Banking;
      var
        I, bankTime: Integer;

    begin
      if (InvCount > 0) then // if stuff in inv then look for the bank!
      begin
        markTime(bankTime);
        repeat
          SmartColors('bank'); // I assume this is a status painted on smart
          MakeObj('bank', 5599869, 2, 0.22, 0.53, [ 'ank', 'ank', 'ooth'], ['ank']);
          wait(400 + random(100));
        until bankScreen or (timeFromMark(bankTime) > 20000);
        //now it will repeat MakeObj until it finds the bank screen or times out.

        if BankScreen then
        begin
          writeln('found bank')
          DepositAll;
          wait(150 + random(63));
          Withdraw(0, 0, 14);
          wait(150 + random(67));
          Withdraw(1, 0, 0);
          wait(100 + random(95));
          CloseBank;
        end else
          writeLn('failed to find bank'); { If this displays in the debug box }
      end;                                { Then you know MakeObj failed to find the bank }
    end;                                  { after 20 seconds }
    Wow, I see what I did wrong now, thanks alot!

    Your post was really helpfull, sometimes I just drown in all these lines ~.~

  7. #7
    Join Date
    Mar 2006
    Location
    Belgium
    Posts
    3,564
    Mentioned
    111 Post(s)
    Quoted
    1475 Post(s)

    Default

    Quote Originally Posted by Herbs N Tea View Post
    Thanks for the tip, I didn't even think about adding more lines for debugging :P (I only started this two days ago)
    And it shouldn't be 15, because I want it to keep waiting untill theres no item in slot 28
    My bad, got confused.

    Creds to DannyRS for this wonderful sig!

  8. #8
    Join Date
    May 2013
    Location
    The Netherlands
    Posts
    12
    Mentioned
    0 Post(s)
    Quoted
    3 Post(s)

    Default

    Also,

    Quote Originally Posted by The Mayor View Post
    Simba Code:
    repeat
              SmartColors('bank');
              I := (I + 1);
              wait(1000 + random(224));
            until (I = 5);// not sure what this loop is. Just repeats a 1 sec wait?
    that loop starts with function SmartColors, wich in this case, finds and opens the bank.

    So it tries to open the bank, than waits a second, wich ofcourse isn't very usefull if it ends the procedure after >.<


    With the code you posted it should work, I'm still at school trying this as soon as I get home ^^

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
  •