Hello, guys.
Recently I have encountered strange behaviour.
I have a script, where I iterate through items in bank (i need to withdraw only some, based on my data). As soon as i iterate through withdrawAll(item), the bank gets closed. Do you have any idea, what am i doing wrong? Or is it just some bug? Script is not getting me any message/any error/exception, it just closes the bank.
PS: This happens only if bank is opened for the first time during the script run.
for (Item item : items) {
int sellPrice = getItemSellPrice(item.getName());
if (script.inventory.isFull()) {
script.log("INV IS FULL");
break;
}
if (helper.in_array(item.getName(), saveAll)) {
script.log("Item to save");
continue;
}
if (helper.in_array(item.getName(), restrictedItems)) {
script.log("Restricted item");
continue;
}
if (getItemSellPrice(item.getName()) * item.getAmount() < 3000) {
script.log("Too cheap shit");
continue;
}
if (helper.in_array(item.getName(), saveOne) && item.getAmount() == 1) {
script.log("Have only one, saving");
continue;
} else if(helper.in_array(item.getName(), saveOne)) {
if(noteWithdrawAllButOne(item.getName())) {
continue;
}
script.log("Withdrawing all except one");
} else {
script.log("Withdraw all");
if(noteWithdrawAll(item.getName())) {
continue;
}
}
Sleep.sleep((int) (math.gRandom(2500, bot.rVariation) * bot.rTime));
script.log("NEEEEXT");
}
if (script.inventory.isEmpty()) {
script.log("Inventory still empty after withdraw, ending this shit");
//endJobAndKill();
}
//script.log("Close bank");
//script.bank.close();
action = "sale";
}
(noteWithdrawAll is just help method, worked fine till now)
public boolean noteWithdrawAll(String item) {
if (!script.getBank().isBankModeEnabled(Bank.BankMode.WITHDRAW_NOTE)) {
script.getBank().enableMode(Bank.BankMode.WITHDRAW_NOTE);
Sleep.sleepUntil(() -> script.getBank().isBankModeEnabled(Bank.BankMode.WITHDRAW_NOTE), 3000, 600);
}
int itemCount = (int) itemCount(item);
script.getBank().withdrawAll(item);
Sleep.sleepUntil(() -> itemCount(item) > itemCount, 3000, 600);
return true;
}