Jump to content
Frequently Asked Questions
  • Are you not able to open the client? Try following our getting started guide
  • Still not working? Try downloading and running JarFix
  • Help! My bot doesn't do anything! Enable fresh start in client settings and restart the client
  • How to purchase with PayPal/OSRS/Crypto gold? You can purchase vouchers from other users
  • getBank().isOpen() not working for me.


    kolmassammas

    Recommended Posts

    When I see the logs in my console my last one is interacted with bank. That should mean getBank().isOpen() dosen't work right? My bank opens up but yeah i dosen't recognize it.
    For whatever reason it dosen't open. Is there any other way to deposit all of my invetory to the bank without checking the getBank().isOpen statement.

    image.png

    Link to comment
    Share on other sites

    13 hours ago, Pseudo said:

    You have zero logic to your code, so it'll always try to execute all of those actions, in that order, constantly, so that's the biggest problem. You need to structure your code. Secondly you ought to now use DB3's static API.

     

    [code]

    
    private void exampleBankingMethod() {
        GameObject bank = GameObjects.closest("Bank booth");
        if (!Bank.isOpen()) { // Check if bank ISN'T open
            if (bank != null) { // Check the bank booth exists/isn't null
                if (bank.isOnScreen()) { //Bank exists and we can see it
                    if (bank.interact("Bank")) { //if we clicked the bank
                        sleepUntil(Bank::isOpen, 5000); // wait until bank is open or 5 seconds have passed
                    }
                } else { // Bank exists but we can't see it! Need to turn to it or move to it
                    Walking.walk(bank.getTile().getRandomizedTile(2)); //Move to the bank
                }
            } else { //If bank is null do this
                Walking.walk(ourTargetBankLocationTile);
            }
        } else { //If bank IS open do this
            if (!Inventory.isEmpty()) { //If theres items in inventory do this
                if (Bank.depositAllItems()) {
                    sleepUntil(Inventory::isEmpty, 3000); //dynamic sleep to wait until we deposited our items
                }
            } else {
                //We don't have items, do we withdraw or do we exit the bank?
                if (Bank.close()) {
                    sleepUntil(() -> !Bank.isOpen(), 3000); // wait until bank is closed or 3 seconds have passed
                }
            }
        }
    }

    [/code]

     

    Just minced this together to try and help you better understand how operations should be handled.

    Thanks, at first i got this really weird error message with your code. Hasseled a bit. Found out i had to reintall my intellij and dreambot. 

    Now your code is working flawlessly. 

    This really helped me with constructing logic in my programs.

    Again Thanks.

    Link to comment
    Share on other sites

    On 12/29/2020 at 1:47 AM, Pseudo said:

    You have zero logic to your code, so it'll always try to execute all of those actions, in that order, constantly, so that's the biggest problem. You need to structure your code. Secondly you ought to now use DB3's static API.

     

    [code]

    
    private void exampleBankingMethod() {
        GameObject bank = GameObjects.closest("Bank booth");
        if (!Bank.isOpen()) { // Check if bank ISN'T open
            if (bank != null) { // Check the bank booth exists/isn't null
                if (bank.isOnScreen()) { //Bank exists and we can see it
                    if (bank.interact("Bank")) { //if we clicked the bank
                        sleepUntil(Bank::isOpen, 5000); // wait until bank is open or 5 seconds have passed
                    }
                } else { // Bank exists but we can't see it! Need to turn to it or move to it
                    Walking.walk(bank.getTile().getRandomizedTile(2)); //Move to the bank
                }
            } else { //If bank is null do this
                Walking.walk(ourTargetBankLocationTile);
            }
        } else { //If bank IS open do this
            if (!Inventory.isEmpty()) { //If theres items in inventory do this
                if (Bank.depositAllItems()) {
                    sleepUntil(Inventory::isEmpty, 3000); //dynamic sleep to wait until we deposited our items
                }
            } else {
                //We don't have items, do we withdraw or do we exit the bank?
                if (Bank.close()) {
                    sleepUntil(() -> !Bank.isOpen(), 3000); // wait until bank is closed or 3 seconds have passed
                }
            }
        }
    }

    [/code]

     

    Just minced this together to try and help you better understand how operations should be handled.

    I want to emphasize that you're getting the bank object even if bank is already open. Only search for entities when you need them. In the worst case I have seen a scripter find dozens of entities in the beginning of each loop, and not even using any of them during that loop.

    Link to comment
    Share on other sites

    6 hours ago, Hashtag said:

    I want to emphasize that you're getting the bank object even if bank is already open. Only search for entities when you need them. In the worst case I have seen a scripter find dozens of entities in the beginning of each loop, and not even using any of them during that loop.

    Yeah nice catch!

    Link to comment
    Share on other sites

    Archived

    This topic is now archived and is closed to further replies.

    ×
    ×
    • Create New...

    Important Information

    We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.