5uck Posted October 19, 2013 Share Posted October 19, 2013 public void toggleRun() throws Exception { if (currentTab() != Tab.SETTINGS) { openTab(Tab.SETTINGS); sleep(300+random(700)); } client.getInterface(261).getChild(34).interact(); } quick fix until the hook is updated in the api. 1 Link to comment Share on other sites More sharing options...
Mr Asshole Posted October 19, 2013 Share Posted October 19, 2013 (edited) You know it will keep trying to do this if you reloop it xD? Better to use configs imo. Edited October 19, 2013 by Pain 1 Link to comment Share on other sites More sharing options...
Joseph Posted October 19, 2013 Share Posted October 19, 2013 private void toogleRun() throws InterruptedException { if (client.getRunEnergy()>=50 && !this.isRunning()) { selectInterfaceOption(548, 34, "Options"); sleep(random(1200, 1800)); selectInterfaceOption(261, 34, "Toggle Run"); sleep(random(1200, 1800)); } } mine Link to comment Share on other sites More sharing options...
Mr Asshole Posted October 19, 2013 Share Posted October 19, 2013 private void toogleRun() throws InterruptedException { if (client.getRunEnergy()>=50 && !this.isRunning()) { selectInterfaceOption(548, 34, "Options"); sleep(random(1200, 1800)); selectInterfaceOption(261, 34, "Toggle Run"); sleep(random(1200, 1800)); } }mineAdd some failsafes to that. 1 Link to comment Share on other sites More sharing options...
5uck Posted October 19, 2013 Author Share Posted October 19, 2013 >.< your script should already account for failsafes and relooping.... this is simply to replace the setRunning() method in the mean time. Link to comment Share on other sites More sharing options...
liverare Posted October 19, 2013 Share Posted October 19, 2013 (edited) /** * The <code>openTab(Setting)</code> will automatically check to make sure * that the desired tab is already present. If not, it will open it. * * Thereafter, we can check to see if we interact with the "run" toggle * button by returning whether we interacted with it via * <code>selectInterfaceOption(int, int)</code> * * @return * <tt>We interacted with the "run" toggle button</tt> * @throws InterruptedException * Interaction was interrupted */ public boolean toggleRun() throws InterruptedException { return openTab(Tab.SETTINGS) && selectInterfaceOption(261, 34); } Edited October 19, 2013 by liverare Link to comment Share on other sites More sharing options...
Joseph Posted October 19, 2013 Share Posted October 19, 2013 private void toogleRun() throws InterruptedException { if (client.getRunEnergy()>=50 && !this.isRunning()) { selectInterfaceOption(548, 34, "Options"); sleep(random(1200, 1800)); selectInterfaceOption(261, 34, "Toggle Run"); sleep(random(1200, 1800)); } }mineAdd some failsafes to that. what you mean failsafe, it always get it on the first try lol Link to comment Share on other sites More sharing options...
Boots Posted October 19, 2013 Share Posted October 19, 2013 if(script.client.getMyPlayer()!=null && !script.isRunning() ) script.setRunning(true); 1 Link to comment Share on other sites More sharing options...
Joseph Posted October 19, 2013 Share Posted October 19, 2013 if(script.client.getMyPlayer()!=null && !script.isRunning() ) script.setRunning(true); they need to update their method its a bit fucked up Link to comment Share on other sites More sharing options...
Anon Posted October 19, 2013 Share Posted October 19, 2013 I would use configs but that is good Link to comment Share on other sites More sharing options...
Celeos Posted October 19, 2013 Share Posted October 19, 2013 These temp fixes are still better than original method due to its missclicking on random interfaces in the settings tab. Link to comment Share on other sites More sharing options...
Mr Asshole Posted October 20, 2013 Share Posted October 20, 2013 private void setRun() throws InterruptedException { if (currentTab() != Tab.SETTINGS){ openTab(Tab.SETTINGS); sleep(random(300,500)); } if (currentTab() == Tab.SETTINGS){ if (client.getInterface(261)!= null){ client.getInterface(261).getChild(34).interact("Toggle Run"); sleep(random(300,500)); } if (client.getConfig(173) == 0){ return; } } } Link to comment Share on other sites More sharing options...
Joseph Posted October 20, 2013 Share Posted October 20, 2013 wow big money baller, my method is 4 line and still does the same thing that yours does :P Link to comment Share on other sites More sharing options...
Mr Asshole Posted October 20, 2013 Share Posted October 20, 2013 wow big money baller, my method is 4 line and still does the same thing that yours does I'd rather do it right the first time rather than misclick the first time and reloop. Link to comment Share on other sites More sharing options...
liverare Posted October 20, 2013 Share Posted October 20, 2013 (edited) private void setRun() throws InterruptedException { if (currentTab() != Tab.SETTINGS){ openTab(Tab.SETTINGS); sleep(random(300,500)); } if (currentTab() == Tab.SETTINGS){ if (client.getInterface(261)!= null){ client.getInterface(261).getChild(34).interact("Toggle Run"); sleep(random(300,500)); } if (client.getConfig(173) == 0){ return; } } } Up yo' game, bitch ********a. Let's safe it like a motherfucker: /** * @param on * The state the run will be set to * @return * <tt>Run is toggled off/on to our desire</tt> * @throws InterruptedException * Interactions were interrupted */ public boolean setRun(boolean on) throws InterruptedException { // Find out the current state of "run" int i = client.getConfig(173); // Declare a new RS2Interface variable for later RS2Interface j = null; // Check to see if the state is on and that's our desired outcome, or // vice versa if ((on && i == 1) || (!on && i == 0)) return true; // Successful state--even if no interactions were // needed. Return true. // Check to see if we "can't" open Setting's tab else if (!openTab(Tab.SETTINGS)) { // We can't, so that's a problem. throw new RuntimeException("Unable to open the Setting's tab!"); // Define the interface variable and check to see if it doesn't // exist or it does, but isn't valid. } else if ((j = client.getInterface(261)) == null || !j.isValid()) { // The interface is either null or invalid, so that's a problem throw new RuntimeException( "We're in Settings, but the interface isn't valid!?"); /* * Final selector state, assume: * 1. Our desired Run state isn't selected * 2. We're in the Setting's tab * 3. The "j" RS2Interface variable exists and is valid */ } else { // Assume that there's no client change, so the child "34" is valid and interact. /* * EDITED CODE (thanks Xavier): * This function WILL ONLY RETURN FALSE if we did NOT interact * with the 'run' toggle-button. This condition will determine * whether another recursive check is exhibited. * * Recurse through this entire method again. The next recursion * should end right at the first selector that checks the desired * state to the actual state. * * Use the same parameter as before */ return j.getChild(34).interact() && setRun(on); } } Without comments, yo': /** * @param on * The state the run will be set to * @return * <tt>Run is toggled off/on to our desire</tt> * @throws InterruptedException * Interactions were interrupted */ public boolean setRun(boolean on) throws InterruptedException { int i = client.getConfig(173); RS2Interface j = null; if ((on && i == 1) || (!on && i == 0)) return true; else if (!openTab(Tab.SETTINGS)) { throw new RuntimeException("Unable to open the Setting's tab!"); } else if ((j = client.getInterface(261)) == null || !j.isValid()) { throw new RuntimeException( "We're in Settings, but the interface isn't valid!?"); } else { return j.getChild(34).interact() && setRun(on); } } Xavier caught a flaw in my first code-post, so I've updated them. The problem being: The old bool method wouldn't have returned false at any point, but rather; return true or throw exceptions. Good catch, Xavier. Hat's off to you, good sir. Edited October 20, 2013 by liverare 1 Link to comment Share on other sites More sharing options...