MySQLi Posted June 24, 2017 Share Posted June 24, 2017 Hey guys, here are my problems with this script, then I'll post the code. When at the Yew Tree in Varrock, even though I have a ConditionalSleep, it still spam clicks the tree Once the tree is cut down once, it won't click on the tree once it respawns Once the inventory is full, it won't walk to the bank, If I walk the player to the bank, it won't open the bank, deposit the logs. Spoiler import org.osbot.rs07.api.Bank; import org.osbot.rs07.api.Inventory; import org.osbot.rs07.api.map.Position; import org.osbot.rs07.api.map.constants.Banks; import org.osbot.rs07.api.model.RS2Object; import org.osbot.rs07.api.util.ItemContainer; import org.osbot.rs07.script.Script; import org.osbot.rs07.script.ScriptManifest; import org.osbot.rs07.utility.ConditionalSleep; import java.awt.*; @ScriptManifest(author = "MySQLi", info = "Varrock Yew Cutter / Banker", name = "SqlYewCutter", version = 1.0, logo = "") public class Main extends Script { @Override public void onStart() { log("Enjoy cutting yews!"); //Code here will execute before the loop is started } public int onLoop() throws InterruptedException{ if(canCutTrees()){ cut(); } else{ bank(); } return random (150,200); //The amount of time in milliseconds before the loop starts over } @Override public void onExit() { log("Thank you for supporting my script!"); //Code here will execute after the script ends } private void bank() throws InterruptedException{ if(inventory.isFull() && !Banks.VARROCK_EAST.contains(myPosition())){ getWalking().webWalk(Banks.VARROCK_EAST); } else if (!getBank().isOpen()){ getBank().open(); getBank().depositAll("Yew Logs"); } else{ getWalking().walk(new Position(3247,3472,0)); } } private void cut(){ RS2Object yew = getObjects().closest("Yew"); if(yew != null && yew.interact("Chop down")); new ConditionalSleep(5000){ public boolean condition(){ return myPlayer().isAnimating() || !yew.exists(); } }.sleep(); } public boolean canCutTrees(){ return myPlayer().isOnScreen(); } @Override public void onPaint(Graphics2D g) { //This is where you will put your code for paint(s) } } Quote Link to comment Share on other sites More sharing options...
progamerz Posted June 24, 2017 Share Posted June 24, 2017 (edited) 42 minutes ago, MySQLi said: Hey guys, here are my problems with this script, then I'll post the code. When at the Yew Tree in Varrock, even though I have a ConditionalSleep, it still spam clicks the tree Once the tree is cut down once, it won't click on the tree once it respawns Once the inventory is full, it won't walk to the bank, If I walk the player to the bank, it won't open the bank, deposit the logs. Hide contents import org.osbot.rs07.api.Bank; import org.osbot.rs07.api.Inventory; import org.osbot.rs07.api.map.Position; import org.osbot.rs07.api.map.constants.Banks; import org.osbot.rs07.api.model.RS2Object; import org.osbot.rs07.api.util.ItemContainer; import org.osbot.rs07.script.Script; import org.osbot.rs07.script.ScriptManifest; import org.osbot.rs07.utility.ConditionalSleep; import java.awt.*; @ScriptManifest(author = "MySQLi", info = "Varrock Yew Cutter / Banker", name = "SqlYewCutter", version = 1.0, logo = "") public class Main extends Script { @Override public void onStart() { log("Enjoy cutting yews!"); //Code here will execute before the loop is started } public int onLoop() throws InterruptedException{ if(canCutTrees()){ cut(); } else{ bank(); } return random (150,200); //The amount of time in milliseconds before the loop starts over } @Override public void onExit() { log("Thank you for supporting my script!"); //Code here will execute after the script ends } private void bank() throws InterruptedException{ if(inventory.isFull() && !Banks.VARROCK_EAST.contains(myPosition())){ getWalking().webWalk(Banks.VARROCK_EAST); } else if (!getBank().isOpen()){ getBank().open(); getBank().depositAll("Yew Logs"); } else{ getWalking().walk(new Position(3247,3472,0)); } } private void cut(){ RS2Object yew = getObjects().closest("Yew"); if(yew != null && yew.interact("Chop down")); new ConditionalSleep(5000){ public boolean condition(){ return myPlayer().isAnimating() || !yew.exists(); } }.sleep(); } public boolean canCutTrees(){ return myPlayer().isOnScreen(); } @Override public void onPaint(Graphics2D g) { //This is where you will put your code for paint(s) } } First of all the boolean canCutTree is wrong, it is just checking if player is on screen, while it should check if player is not animating and yew is not null and inventory is not full and check equipment for anyitem that contains "axe" or inventory has anything that contains "axe". cut() condition sleep only sleeps untill animating, add another sleep to sleep untill is not animating or inventory is full. private void cut() { RS2Object yew = getObjects().closest("Yew"); if (yew != null && yew.interact("Chop down")) { new ConditionalSleep(5000) { public boolean condition() { return myPlayer().isAnimating() || !yew.exists(); } }.sleep(); new ConditionalSleep(5000) { public boolean condition() { return !myPlayer().isAnimating() || !yew.exists() || inventory.isFull(); } }.sleep(); } } public boolean canCutTrees(){ return YEWAREA.contains(myPlayer()) && (getInventory().contains(f -> f.getName().contains("axe")) || getmp().getEquipment().contains(f -> f.getName().contains("axe"))) && !myPlayer().isAnimating() && !myPlayer().isMoving() && !getInventory().isFull(); } The YEWAREA is where u define the area for the Yews. you can change it. One more tip, try to format the code in your IDE for us to be able to help more. Edited June 24, 2017 by progamerz Quote Link to comment Share on other sites More sharing options...
Juggles Posted June 24, 2017 Share Posted June 24, 2017 (edited) So much wrong with this. Don't even know where to start. Just leech off my code https://pastebin.com/wFGP0F29 Thanks that'll be 2m Edited June 24, 2017 by Juggles Quote Link to comment Share on other sites More sharing options...
Nate Posted June 24, 2017 Share Posted June 24, 2017 18 minutes ago, Juggles said: So much wrong with this. Don't even know where to start. Just leech off my code https://pastebin.com/wFGP0F29 Thanks that'll be 2m nice now I can add a log message and sell my private wc script Quote Link to comment Share on other sites More sharing options...
MySQLi Posted June 24, 2017 Author Share Posted June 24, 2017 2 hours ago, progamerz said: tEquipm 1 hour ago, Juggles said: So much wrong with this. Don't even know where to start. Just leech off my code https://pastebin.com/wFGP0F29 Thanks that'll be 2m I appreciate that, I'm having a lot of trouble learning how to write scripts, there so many different guides, and things to learn, I'm having trouble where to start, and every guide is different with how people do things so I'm getting mixed up. I appreciate everyone's help though. Quote Link to comment Share on other sites More sharing options...