Jump to content

Simple buying script help


queshy

Recommended Posts

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.

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