Jump to content

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


Recommended Posts

Posted

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!

Posted (edited)

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
Posted (edited)

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

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...