Jump to content

Simple buying script help


Recommended Posts

Posted

Hey guys, recently started developing with the OSbot API & Java, was wondering if some more experienced developers could take a look at my script and help with a few issues.

Most notably, it seems to loop over trading twice or three times before buying / hoping worlds and ive noticed it wont deposit the vials until the second trip has been completed.

Thanks!

    @Override
    public final int onLoop() throws InterruptedException {
        if (!STORE.contains(myPosition())) {
            getWalking().webWalk(STORE);
        } else if (!getInventory().contains("Example item")) {
            if (!getStore().isOpen()) {
                getNpcs().closest("Assistant").interact("Trade");
            }
            if (getStore().getAmount("Example item") >= 950 && getStore().isOpen()) {
                getStore().buy("Example item", 50);
                getStore().close();
            } else {
                getStore().close();
                getWorlds().hopToP2PWorld();
                sleep(5000);
            }
        } else if (getInventory().contains("Example item")) {
            getWalking().webWalk(BANK);
            if (!getBank().isOpen()) {
                getBank().open();
            }
            getBank().depositAll("Example item");
            getBank().withdraw("Energy potion(1)",1);
            getInventory().getItem("Energy potion(1)").interact("Drink");
            sleep(500);
            getBank().depositAll("Vial");
            getBank().close();
        }
        if (!getInventory().contains("Coins") || getInventory().getAmount("Coins") <= 200) {
            stop();
        }

        return 0;
    }

 

** the vial issue seems to be everynow and again. Im sure this has something to do with waits and sleeps but any help would be appreciated.

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
  • Recently Browsing   0 members

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