queshy Posted February 22, 2023 Share Posted February 22, 2023 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. Quote Link to comment Share on other sites More sharing options...
Gunman Posted February 22, 2023 Share Posted February 22, 2023 Try to keep 1 interaction per cycle of the on loop and check your interactions as they return a Boolean and use conditional sleeps Quote Link to comment Share on other sites More sharing options...
SlimGirl Posted February 22, 2023 Share Posted February 22, 2023 As Gunman said you should be using many conditional sleeps for something like this. Look at section 9 of Explv's Scripting 101 for an example and explanation. Quote Link to comment Share on other sites More sharing options...