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
  • Try asking for help in the chatbox
  • Bank Deposit Questions


    SyarTheTitan
     Share

    Recommended Posts

    Hello everyone I've recently gotten into scripting but I do have a background in Java. I was making a simple WC bot, but I am having trouble having the bot actually deposit the items. 

    My code is as follows.

    if(!BankLocation.LUMBRIDGE.getArea(2).contains(getLocalPlayer()))// Check to see that I am not in the bank area. 
                {
                    getWalking().walk(BankLocation.LUMBRIDGE.getCenter());//Walks to Bank
                    sleepUntil(()-> BankLocation.LUMBRIDGE.getArea(2).contains(getLocalPlayer()),15000);// Sleeps until I am there or 15 seconds have passed
                }
                
    if(getBank().isOpen()) //makes sure it is open
                {
                    getBank().depositAllItems();// Should deposit all items IE logs
                    sleepUntil(()->getBank().depositAllItems(),5000); // waits until process is over or after 5 seconds
                    getBank().close(); //should close the bank haven't gotten to this point yet. 
    
    
    
                    //getBank().deposit("Logs"); // Something I also tried and did not see success with. 
                }
    else// bank is not open
                {//walks over and opens the closest bank
                    getBank().openClosest();
                }
    
    }

     

    I assume that a problem could be the back to back if loops but even when I put in a simple sleep(100) it still did not work, any help would be appreciated. 

     

    Link to comment
    Share on other sites

    Try to avoid doing multiple things at once. Do one thing then end the loop (return)

     

    public class Main extends AbstractScript {
    
        public void onStart() {
        }
    
        @Override
        public int onLoop() {
            if (!getBank().isOpen()) { // checks if banking window is not open
                if (getInventory().contains("Bones")) {
                    getBank().deposit("Bones"); // deposit one bone
                    return Calculations.random(2500, 10000);
    
                } else {
                    getBank().close(); // no more bones in inventory so closing banking window
                    return Calculations.random(1000, 5000);
                }
    
    
            } else {
                getBank().open(getBank().getClosestBankLocation()); // walks to closest bank and opens banking window
                return Calculations.random(3000, 10000);
            }
        }
    }

     

    Link to comment
    Share on other sites

    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
     Share

    ×
    ×
    • 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.