Nor3g Posted February 14, 2019 Share Posted February 14, 2019 import org.osbot.rs07.api.map.constants.Banks; import org.osbot.rs07.api.ui.Message; import org.osbot.rs07.script.Script; import org.osbot.rs07.script.ScriptManifest; @ScriptManifest(name = "muler", author = "Nor3g", version = 1.0, info = "muler", logo = "") public class Muler extends Script { String thebot = getParameters(); String thebotrep = thebot.replace(' ', '\u00A0'); @Override public void onStart() { //Code here will execute before the loop is started } @Override public void onExit() { System.exit(0); //Code here will execute after the script ends } @Override public int onLoop() throws InterruptedException { if (!Banks.VARROCK_WEST.contains(myPosition())) { getWalking().webWalk(Banks.VARROCK_WEST); } else if (Banks.VARROCK_WEST.contains(myPosition()) && getPlayers().closest(thebotrep) != null) { getPlayers().closest(thebotrep).interact("Trade with"); sleep(random(450, 5000)); } else if (!trade.getOtherPlayer().equals(thebotrep)) { trade.declineTrade(); sleep(random(450, 5000)); } else if (!trade.getTheirOffers().contains("Coins")) { sleep(random(450, 5000)); } else if (trade.getTheirOffers().contains("Coins")) { trade.acceptTrade(); sleep(random(450, 5000)); } else if (trade.isSecondInterfaceOpen()) { if (!trade.acceptTrade()) { trade.acceptTrade(); sleep(random(450, 5000)); } } return 100; //The amount of time in milliseconds before the loop starts over } public void onMessage(Message message) { if (message.getMessage().contains("Accepted trade.")) { stop(); } } } Im trying to test out my Mulescript, but it won't start. I tried to run it with this CLI command: java -jar "osbot 2.5.38.jar" -login Nor3g:password -bot name:pass:1234 -script muler:thebot Or more correctly, it's a bat file that is in the same folder that the osbot client is. The client launches, however the bot doesn't start, or maybe it does. I can't click on anything within the game, yet the option to pause/stop is grayed out and unclickable. It's the same error if I start the client manually and select the script to be ran manually. It won't even start the login randomsolver. Any help is very much appreciated! Quote Link to comment Share on other sites More sharing options...
d0zza Posted February 14, 2019 Share Posted February 14, 2019 Move these lines: String thebot = getParameters(); String thebotrep = thebot.replace(' ', '\u00A0'); to your onStart Quote Link to comment Share on other sites More sharing options...
Nor3g Posted February 14, 2019 Author Share Posted February 14, 2019 (edited) 18 minutes ago, d0zza said: Move these lines: String thebot = getParameters(); String thebotrep = thebot.replace(' ', '\u00A0'); to your onStart I get a nullpointer exception here at the else if line: } else if (!trade.getOtherPlayer().equals(thebotrep)) { trade.declineTrade(); sleep(random(450, 5000)); and i tried to log what thebot and thebotrep came out as, and they came out as 31, the first number in the parameter, say it should be "31 botter" Edited February 14, 2019 by Nor3g Quote Link to comment Share on other sites More sharing options...
Iwin Posted February 14, 2019 Share Posted February 14, 2019 (edited) 1 hour ago, Nor3g said: import org.osbot.rs07.api.map.constants.Banks; import org.osbot.rs07.api.ui.Message; import org.osbot.rs07.script.Script; import org.osbot.rs07.script.ScriptManifest; @ScriptManifest(name = "muler", author = "Nor3g", version = 1.0, info = "muler", logo = "") public class Muler extends Script { String thebot = getParameters(); String thebotrep = thebot.replace(' ', '\u00A0'); @Override public void onStart() { //Code here will execute before the loop is started } @Override public void onExit() { System.exit(0); //Code here will execute after the script ends } @Override public int onLoop() throws InterruptedException { if (!Banks.VARROCK_WEST.contains(myPosition())) { getWalking().webWalk(Banks.VARROCK_WEST); } else if (Banks.VARROCK_WEST.contains(myPosition()) && getPlayers().closest(thebotrep) != null) { getPlayers().closest(thebotrep).interact("Trade with"); sleep(random(450, 5000)); } else if (!trade.getOtherPlayer().equals(thebotrep)) { trade.declineTrade(); sleep(random(450, 5000)); } else if (!trade.getTheirOffers().contains("Coins")) { sleep(random(450, 5000)); } else if (trade.getTheirOffers().contains("Coins")) { trade.acceptTrade(); sleep(random(450, 5000)); } else if (trade.isSecondInterfaceOpen()) { if (!trade.acceptTrade()) { trade.acceptTrade(); sleep(random(450, 5000)); } } return 100; //The amount of time in milliseconds before the loop starts over } public void onMessage(Message message) { if (message.getMessage().contains("Accepted trade.")) { stop(); } } } Im trying to test out my Mulescript, but it won't start. I tried to run it with this CLI command: java -jar "osbot 2.5.38.jar" -login Nor3g:password -bot name:pass:1234 -script muler:thebot Or more correctly, it's a bat file that is in the same folder that the osbot client is. The client launches, however the bot doesn't start, or maybe it does. I can't click on anything within the game, yet the option to pause/stop is grayed out and unclickable. It's the same error if I start the client manually and select the script to be ran manually. It won't even start the login randomsolver. Any help is very much appreciated! public class Muler extends Script { String thebot = getParameters(); String thebotrep; @Override public void onStart() { thebotrep = thebot.replace(' ', '\u00A0'); } This will work Edited February 14, 2019 by Iwin 1 Quote Link to comment Share on other sites More sharing options...
Nor3g Posted February 14, 2019 Author Share Posted February 14, 2019 44 minutes ago, Iwin said: This will work Yes it does thank you, I've fixed it. Only problem now is the bot stops at the second trade interface and does absolutely nothing. else if (trade.isSecondInterfaceOpen()) { trade.acceptTrade(); sleep(random(450, 5000)); } Im absolutely clueless as to how I'm going to fix this, all help is greatly appreciated! Quote Link to comment Share on other sites More sharing options...
ItPoke Posted February 14, 2019 Share Posted February 14, 2019 (edited) Move that up to be the first if statement, and see what happens! Heres a good old spoon feed of how I would do it. Please ask whats going on so you understand! GL HF if (!trade.isCurrentlyTrading()) { // Get into trading if (!Banks.VARROCK_WEST.contains(myPosition())) { // Walk to bank if we are not there getWalking().webWalk(Banks.VARROCK_WEST); } if (Banks.VARROCK_WEST.contains(myPosition()) && getPlayers().closest(thebotrep) != null) { if (!getPlayers().closest(thebotrep).interact("Trade with")) // Trying to trade return random(450, 5000); // Trade interaction failed, returning to reset and skip everything below new ConditionalSleep(15000) { // Waiting 15 sec or until we have started trading @Override public boolean condition() throws InterruptedException { return trade.isCurrentlyTrading(); } }.sleep(); if (!trade.isCurrentlyTrading()) // Trading window not open yet! return random(450, 5000); // Returning to reset and skip everything below } } if (!trade.getOtherPlayer().equals(thebotrep)) { // Making sure we only trade out bot trade.declineTrade(); return random(450, 5000); // Returning to reset and skip everything below } if (!trade.isSecondInterfaceOpen() && trade.getTheirOffers().contains("Coins")) { // Waiting for coins trade.acceptTrade(); new ConditionalSleep(15000) { // Wait 15 sec or until we get to the second trade interface @Override public boolean condition() throws InterruptedException { return trade.isSecondInterfaceOpen(); } }.sleep(); } if (trade.isSecondInterfaceOpen()) { // Accept if we are on second trade interface trade.acceptTrade(); } NOT TESTED! Edited February 14, 2019 by ItPoke Spoon feeding Quote Link to comment Share on other sites More sharing options...
Medusa Posted February 14, 2019 Share Posted February 14, 2019 Not actually trying to help with your problem, but in future scripts you might wanna use this It's a great guide on how to actually do task based scripting, instead of storing all of your code inside the onLoop() method. 1 Quote Link to comment Share on other sites More sharing options...
d0zza Posted February 14, 2019 Share Posted February 14, 2019 17 hours ago, Nor3g said: I get a nullpointer exception here at the else if line: } else if (!trade.getOtherPlayer().equals(thebotrep)) { trade.declineTrade(); sleep(random(450, 5000)); and i tried to log what thebot and thebotrep came out as, and they came out as 31, the first number in the parameter, say it should be "31 botter" That's because when launching through CLI the space in "31 botter" indicates that the next argument has begun. Instead use this CLI param to run the script: -script muler:31-botter Then in your onstart do String thebot = getParameters(); String thebotrep = thebot.replace('-', '\u00A0'); Quote Link to comment Share on other sites More sharing options...