Nex 2546 Posted June 18, 2017 Im gonna try to explain it as best as i can feel free to comment below what i should add into this guide To start off every script needs this for the client to be able to read/start it, @ScriptManifest(author = "You", name = "Script Name", version = Version, description = "", category = Category of the script) public class main extends AbstractScript { Script Skeleton: So with this in mind were gonna build up a skeleton for the script, all scripts need this: (onExit isnt needed but usefull for infomation) @ScriptManifest(author = "Nex", name = "Nex Tree Assasin", version = 0.1, description = "Harrasing tree's", category = Category.WOODCUTTING) public class main extends AbstractScript { @Override public void onStart() { } @Override public int onLoop() { return 0; } @Override public void onExit() { } } onStart(): Here you place anything that will be used at the beginning of a script, Example: @Override public void onStart() { log("Starting!"); } onExit(): Same as with onStart() but this will show when stopping the script, Example: @Override public void onExit() { log("Stopping!"); } onLoop(): This is where the majority of you're script will take place will go into detail on this later, Complete Script: For the Leechers: 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; @ScriptManifest(author = "Nex", name = "Nex Tree Assasin", version = 0.1, description = "Harrasing tree's", category = Category.WOODCUTTING) public class main extends AbstractScript { @Override public void onStart() { log("Starting!"); // This will display in the CMD or logger on dreambot } @Override public int onLoop() { if (getInventory().isFull()) { // Here we check if the inventory is full. getInventory().dropAll("Logs"); // Here we drop all items IF the inventory is full, we specificly telling it to only drop "Logs" sleep(300,500); // This is a basic sleep meaning it will wait for 0,3-0,5 sec } else { // if the inventory isnt full, the script will move on to the next part "else" if inv isnt full. GameObject tree = getGameObjects().closest("Tree"); // Here we define what a tree is in the script, it will search for the nearest game object with the name "Tree" if (tree != null) { // Null check so tree isnt nulled. tree.interact("Chop down"); // Here we say it has to interact with the tree the interaction is "Chop down" sleep(500,600); // This is a basic sleep meaning it will wait for 0,5-0,6 sec sleepUntil(() -> !getLocalPlayer().isAnimating() , 15000); // this will make the bot sleep untill its animating (moving in this case chopping a tree) the 5000 in the end means it will wait 15 sec or re-attempt } } return 300; // basic return value. } @Override public void onExit() { log("Stopping!"); // this will display in the CMD or logger on dreambot } }
Nex 2546 Author Posted June 18, 2017 Nice one But why are all Tutorials based on Woodcutting because most people start off making a woodcutter + its easy Cool tutorial. thanks
templex 5 Posted November 11, 2017 getting an error https://gyazo.com/d4b15337d1a1c86923f273305a15baf6 ?
Manly 879 Posted November 11, 2017 getting an error https://gyazo.com/d4b15337d1a1c86923f273305a15baf6 ? Are you using Java 8?
Recommended Posts
Archived
This topic is now archived and is closed to further replies.