Jump to content
Frequently Asked Questions
  • Are you not able to open the client? Make sure you have Java 8 installed
  • Help! My bot doesn't do anything! Enable fresh start in client settings and restart the client
  • How to purchase with PayPal/OSRS gold? You can purchase vouchers from other users
  • Try asking for help in the chatbox

DreamBot is the only Deadman Mode supported bot on the market!

Download the DreamBot client today!





G_G

Members
  • Content Count

    23
  • Joined

  • Last visited

  1. This is the latest version I was trying. The last line in the log is "Check completed", but it doesn't do anything after that. import org.dreambot.api.script.ScriptManifest; // API can be found here: https://dreambot.org/javadocs/ import org.dreambot.api.script.impl.TaskScript; import org.dreambot.api.methods.map.Area; import org.dreambot.api.script.Category; @ScriptManifest(author = "G_G", name = "Smither", version = 0.1, description = "Smith Iron Platebodies", category = Category.SMITHING) public class Main extends TaskScript { private static Area bankArea = new Area(3181, 3439, 3185, 3435, 0); private static Area smithArea = new Area(3186, 3426, 3189, 3424, 0); /** * When the user starts the script, this code gets run once in the beginning. */ @Override public void onStart() { log("STARTING!"); addNodes(new BankNode(), new SmithNode()); } @Override public void onExit() { log("STOPPED!"); } //////////////////////////GETTERS/////////////////////////////// /* * Getter function for the banking area */ static Area getBankArea(){ return bankArea; } /* * Getter function for the smithing area */ static Area getSmithArea() { return smithArea; } } import org.dreambot.api.methods.Calculations; import org.dreambot.api.script.TaskNode; import org.dreambot.api.wrappers.interactive.NPC; /* * @author G_G * @version 1.0 * @date 31/08/2019 */ public class BankNode extends TaskNode { @Override public int priority() { return 2; } /* * This node will only be executed if this method returns true. * * @return true if all conditions are met. */ @Override public boolean accept() { return inventoryCheck(); } /* * This acts as the loop where we will interact with the game. Ideal logic is to * have one action per loop to avoid unexpected incidents such as lag spikes * messing with our script. * * @return time in milliseconds to sleep before looping again. */ @Override public int execute() { if (Main.getBankArea().contains(getLocalPlayer())) { bank(); } else { if (getWalking().walk(Main.getBankArea().getRandomTile())) { sleep(Calculations.random(3000, 5500)); } } return Calculations.random(300, 600); } ///////////////////////////////////////////////////////////////////// /* * Check if the necessary items are in the inventory. */ private boolean inventoryCheck() { boolean status = false; if (getInventory().contains("Hammer") && getInventory().count("Iron bar") > 5) { status = true; } return status; } /* * Method for banking. */ private void bank() { NPC banker = getNpcs().closest(npc -> npc != null && npc.hasAction("Bank")); if (banker != null && banker.interact("Bank")) { if (sleepUntil(() -> getBank().isOpen(), 9000)) { if (getBank().depositAllExcept(item -> item != null && item.getName().contains("Hammer"))) { if (sleepUntil(() -> !getInventory().contains("Iron Platebody"), 8000)) { if (getBank().withdrawAll(item -> item != null && item.getName().contains("Iron bar"))) { if (sleepUntil(() -> !getInventory().contains("Iron bar"), 8000)) { if (getBank().close()) { sleepUntil(() -> !getBank().isOpen(), 8000); } } } } } } } } } import org.dreambot.api.methods.Calculations; import org.dreambot.api.script.TaskNode; import org.dreambot.api.wrappers.interactive.GameObject; import org.dreambot.api.wrappers.widgets.WidgetChild; /* * @author G_G * @version 1.0 * @date 31/08/2019 */ public class SmithNode extends TaskNode { /* * Every node has its own priority. The higher the priority number is, the more * important it is. * * @return priority of this node */ @Override public int priority() { return 1; } /* * This node will only be executed if this method returns true. * * @return true if all conditions are met. */ @Override public boolean accept() { return true; } /* * This acts as the loop where we will interact with the game. Ideal logic is to * have one action per loop to avoid unexpected incidents such as lag spikes * messing with our script. * * @return time in milliseconds to sleep before looping again. */ @Override public int execute() { if (Main.getSmithArea().contains(getLocalPlayer())) { smith(); } else { if (getWalking().walk(Main.getSmithArea().getRandomTile())) { sleep(Calculations.random(3000, 5500)); } } return Calculations.random(300, 600); } /////////////////// METHODS///////////////////////// // Method for smitting private void smith() { GameObject anvil = getGameObjects().closest(gameobject -> gameobject != null && gameobject.hasAction("Smith")); WidgetChild smithItem = getWidgets().getWidgetChild(312, 22); if (anvil != null && anvil.interact("Smith")) { log("Opened interface succesfully"); if (widgetCheck(smithItem)) { log("check completed"); smithItem.interact(); log("Interacted succesfully"); sleepUntil(() -> isFinished(), 8000); log("sleeping"); } } } // Check if the widget is open. private boolean widgetCheck(WidgetChild widget){ boolean check = false; if (widget != null && widget.isVisible() && widget.getItem().getID() == 1205) { check = true; } return check; } // Are we finished smithing? private boolean isFinished() { return getInventory().count("Iron bar") < 5; } }
  2. @NovaGTXI tried both suggestions, but it didn't solve it.
  3. I really like the script, but I've been getting the same error since last week or so.
  4. Thanks for the help! I think I understand how widgets work now, but I still can't get the script to work correctly. I tried to debug by logging different steps and found that the selected widget is allways null and therefore the script will never get to the interact line. Does anybody know what can cause this?
  5. Thanks, that got rid of the error. But the bot still won't interact with the widget. instead it just hovers above another item in the Smithing menu.
  6. Hi, I tried making my first script and I'm getting an NullpointerExeption error that I can't seem to solve. I tried making the code as clear as possible by deviding it into smaller functions, and I'm getting the error when running the smith() function below. Can anybody tell my what I do wrong? private void smith() { GameObject anvil = getGameObjects().closest(gameobject -> gameobject != null && gameobject.hasAction("Smith")); WidgetChild smithItem = getWidgets().getWidget(312).getChild(22); if (anvil != null && anvil.interact("Smith")) { if (widgetCheck(smithItem)) { if(smithItem!= null && smithItem.interact("Smith")) { sleepUntil(() -> isFinished(), 8000); } } } } // Check if the widget is open. private boolean widgetCheck(WidgetChild widget) { return widget != null && widget.isVisible(); } // Are we finished smithing? private boolean isFinished() { return getInventory().count("Iron bar") < 5; //because I only make iron platebodies }
  7. Hi, I'm totally new to coding and I'm getting an error on the import section: - The import org cannot be resolved - Must declare a named package because this compilation unit is associated to the named module 'simpleTeaThief' Do you know what I could have done wrong? import org.dreambot.api.script.AbstractScript; // All these imports are from the dreambot API import org.dreambot.api.script.ScriptManifest; // API can be found here: https://dreambot.org/javadocs/ import org.dreambot.api.script.Category; import org.dreambot.api.wrappers.interactive.GameObject;
  8. G_G

    RQuester

    I upvoted, could I get a trial?
  9. When I'm running the script, it will not select the item to smith. Amy idea what causes this?
  10. Bought a Dreambot voucher. It was really fast and reliable.
×
×
  • Create New...