Jump to content

Bank - Withdraw - Bug, ore just me failing.


azuresuN

Recommended Posts

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;
}
Edited by azuresuN
Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

  • Recently Browsing   0 members

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