Jump to content
View in the app

A better way to browse. Learn more.

OSBot :: 2007 OSRS Botting

A full-screen app on your home screen with push notifications, badges and more.

To install this app on iOS and iPadOS
  1. Tap the Share icon in Safari
  2. Scroll the menu and tap Add to Home Screen.
  3. Tap Add in the top-right corner.
To install this app on Android
  1. Tap the 3-dot menu (⋮) in the top-right corner of the browser.
  2. Tap Add to Home screen or Install app.
  3. Confirm by tapping Install.

Bank withdraw loop causing extra threads to be created???

Featured Replies

Hi all,

I'm running into an issue where a bank withdraw loop I have (it's looped to make sure we withdraw the right amount of items as sometimes the client misclicks, see code below) seems to be spawning extra threads. Any time the loop has to go through 2 or more passes (which is rare), the client starts trying to do multiple actions at once and I can tell from the log that it's running through the loop with multiple instances. No idea why it's spawning this extra process/thread (not sure what exactly it's doing), but here's the code in question from my withdrawIngredients function:

 

        if(!Banks.EDGEVILLE.contains(myPosition())) {
            goToBank();
        }
        while(!bank.isOpen()) {
            bank.open();
            new ConditionalSleep(7000, random(50, 450)) {
                @Override
                public boolean condition() throws InterruptedException {
                    return bank.isOpen();
                }
            }.sleep();
        }
        while(inventory.getAmount("Super strength(4)") != min(amountSuperStr, 7) ||
              inventory.getAmount("Super attack(4)") != min(amountSuperAtk, 7) ||
              inventory.getAmount("Super defense(4)") != min(amountSuperDef, 7) ||
			  inventory.getAmount("Torstol") != min(amountTorstol, 7)) {
            if(!inventory.isEmpty()) bank.depositAll();
            bank.withdraw("Super strength(4)", 7);
            bank.withdraw("Super attack(4)", 7);
            bank.withdraw("Super defense(4)", 7);
            bank.withdraw("Torstol", 7);
            sleep(random(150,300));
        }
            bank.close();

The amountX parameters are how many are left in the bank, we either want the amount remaining or 7.

Thanks for reading!

Why utilise while loop here though?

You can do with if statements


In pseudo-code:
if inventory doesnt contain 7 of str, attack, def, torstol

check if inventory is empty

if it isnt, deposit all

check if bank contains str, attack, def, torstol

withdraw your specified amount of -  str, attack, def, torstol

conditional sleep until inventory contains these items

and bank close

Edited by LagerLV

  • Author

If the bot misclicks while withdrawing, which has happened and is the reason I tried a while loop, will it try and correct itself??

How can it misclick? Hasn't happened to me yet while utilising anything related to bank.

Only difference is i use getBank().withdraw("Item name", amount);
Instead of bank.withdraw

Edit: PM me your whole code so i can take a look at it.

Edited by LagerLV

I feel like those While loop are over kill and not need they will just lead to error.

I wrote this code I hop it will help you

There is 2 options 1 based off Explv's AIO banking code and the other just a basic loop type.

 

    ItemReqBanking x;
    @Override
    public void onStart() throws InterruptedException {

        x= new ItemReqBanking(getContext() ,new ItemReq("Super strength(4)", 1,7) ,new  ItemReq("Super attack(4)",1, 7),  new ItemReq("Super defense(4)",1, 7), new ItemReq("Torstol",1, 7));


    }



    @Override
    public int onLoop() throws InterruptedException {


        if(!Banks.EDGEVILLE.contains(myPosition())) {
            goToBank();
        }else if (getBank().isOpen()){

            //the code I give
    //top
            if (x.souldbank()){
                x.bank();
            }else {
                bank.close();
            }
          //bottom

            //or
          //top
            if (inventory.getAmount("Super strength(4)") < 1){

                bank.withdraw("Super strength(4)", 7);

            }else   if (inventory.getAmount("Super attack(4)") < 1){

                bank.withdraw("Super attack(4)", 7);

            }else  if (inventory.getAmount("Super defense(4)") < 1){

                bank.withdraw("Super defense(4)", 7);


            }else  if (inventory.getAmount("Torstol")< 1){
                bank.withdraw("Torstol", 7);

            }else{
                getBank().close();
            }
//bottom

        }else {
            if (inventory.getAmount("Super strength(4)") == 0 ||
                    inventory.getAmount("Super attack(4)")  == 0 ||
                    inventory.getAmount("Super defense(4)")  == 0 ||
                    inventory.getAmount("Torstol")  == 0){

            getBank().open();


            }else {

                //mix potions
            }

        }



return 1000;



}

    
    public Script getContext() {
        return this;
    }

 

code of ItemReqBanking (it is very mess and just hacky)

http://www.mediafire.com/file/jjfg84fgsr8179y/file

 

Edited by Nbacon

  • Author

Thank you both for your replies!

I ended up switching to a conditionalsleep and using getBank and it worked fine.

Create an account or sign in to comment

Recently Browsing 0

  • No registered users viewing this page.

Account

Navigation

Search

Configure browser push notifications

Chrome (Android)
  1. Tap the lock icon next to the address bar.
  2. Tap Permissions → Notifications.
  3. Adjust your preference.
Chrome (Desktop)
  1. Click the padlock icon in the address bar.
  2. Select Site settings.
  3. Find Notifications and adjust your preference.