gatorwhiter Posted September 1, 2020 Share Posted September 1, 2020 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! Quote Link to comment Share on other sites More sharing options...
LagerLV Posted September 1, 2020 Share Posted September 1, 2020 (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 September 1, 2020 by LagerLV Quote Link to comment Share on other sites More sharing options...
gatorwhiter Posted September 1, 2020 Author Share Posted September 1, 2020 If the bot misclicks while withdrawing, which has happened and is the reason I tried a while loop, will it try and correct itself?? Quote Link to comment Share on other sites More sharing options...
LagerLV Posted September 1, 2020 Share Posted September 1, 2020 (edited) 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 September 1, 2020 by LagerLV Quote Link to comment Share on other sites More sharing options...
Nbacon Posted September 1, 2020 Share Posted September 1, 2020 (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 September 1, 2020 by Nbacon Quote Link to comment Share on other sites More sharing options...
gatorwhiter Posted September 1, 2020 Author Share Posted September 1, 2020 Thank you both for your replies! I ended up switching to a conditionalsleep and using getBank and it worked fine. Quote Link to comment Share on other sites More sharing options...