progamerz Posted September 27, 2017 Share Posted September 27, 2017 (edited) Nvm Edited September 27, 2017 by progamerz Quote Link to comment Share on other sites More sharing options...
Butters Posted September 27, 2017 Share Posted September 27, 2017 God damn so much spam on such an awesome thread. @progamerz you clearly have a problem in your getLobbyButton() method. Just catch that pesky nullPointer and wait until everything is loaded for it to execute properly. Here's mine public RS2Widget getLobbyButton() { try { RS2Widget lobbyButton = widgets.getWidgetContainingText("CLICK HERE TO PLAY"); if (lobbyButton != null) { return lobbyButton; } } catch (NullPointerException e) { s.log("Didn't find lobby button"); } return null; } Quote Link to comment Share on other sites More sharing options...
progamerz Posted September 27, 2017 Share Posted September 27, 2017 1 minute ago, nosepicker said: God damn so much spam on such an awesome thread. @progamerz you clearly have a problem in your getLobbyButton() method. Just catch that pesky nullPointer and wait until everything is loaded for it to execute properly. Here's mine public RS2Widget getLobbyButton() { try { RS2Widget lobbyButton = widgets.getWidgetContainingText("CLICK HERE TO PLAY"); if (lobbyButton != null) { return lobbyButton; } } catch (NullPointerException e) { s.log("Didn't find lobby button"); } return null; } What u did before isn't considered as spam? thanks anyways. Quote Link to comment Share on other sites More sharing options...
Juggles Posted September 27, 2017 Share Posted September 27, 2017 24 minutes ago, progamerz said: What u did before isn't considered as spam? thanks anyways. Maybe we should revert to spoilers when posting code 1 Quote Link to comment Share on other sites More sharing options...
progamerz Posted September 27, 2017 Share Posted September 27, 2017 1 hour ago, Juggles said: Maybe we should revert to spoilers when posting code Ok maybe next time Quote Link to comment Share on other sites More sharing options...
Explv Posted September 27, 2017 Author Share Posted September 27, 2017 4 hours ago, nosepicker said: God damn so much spam on such an awesome thread. @progamerz you clearly have a problem in your getLobbyButton() method. Just catch that pesky nullPointer and wait until everything is loaded for it to execute properly. Here's mine public RS2Widget getLobbyButton() { try { RS2Widget lobbyButton = widgets.getWidgetContainingText("CLICK HERE TO PLAY"); if (lobbyButton != null) { return lobbyButton; } } catch (NullPointerException e) { s.log("Didn't find lobby button"); } return null; } 1 hour ago, progamerz said: Ok maybe next time You could try moving the lobby button check inside of the isLoggedIn check: @Override public final int execute() throws InterruptedException { if (!getBot().isLoaded()) { return 1000; } else if (getClient().isLoggedIn()) { if (getLobbyButton() != null) { clickLobbyButton(); } else { getBot().getScriptExecutor().resume(); setFinished(); } } else if (!getBot().getScriptExecutor().isPaused()) { getBot().getScriptExecutor().pause(); } else if (isOnWorldSelectorScreen()) { cancelWorldSelection(); } else if (!isPasswordEmpty()) { clickCancelLoginButton(); } else { login(); } return random(100, 150); } Quote Link to comment Share on other sites More sharing options...
progamerz Posted September 27, 2017 Share Posted September 27, 2017 12 minutes ago, Explv said: You could try moving the lobby button check inside of the isLoggedIn check: @Override public final int execute() throws InterruptedException { if (!getBot().isLoaded()) { return 1000; } else if (getClient().isLoggedIn()) { if (getLobbyButton() != null) { clickLobbyButton(); } else { getBot().getScriptExecutor().resume(); setFinished(); } } else if (!getBot().getScriptExecutor().isPaused()) { getBot().getScriptExecutor().pause(); } else if (isOnWorldSelectorScreen()) { cancelWorldSelection(); } else if (!isPasswordEmpty()) { clickCancelLoginButton(); } else { login(); } return random(100, 150); } Oh yup makes sense thanks boss , idk why i didn't think of doing it in that way lol Quote Link to comment Share on other sites More sharing options...
Colonel_Panic Posted September 28, 2017 Share Posted September 28, 2017 Do I need to do something to actually get responseCodes when the account is locked? My onResponseCode function is never being called, so it just sits looking at the login screen with the "Your account has been disabled" message. Quote Link to comment Share on other sites More sharing options...
Juggles Posted September 28, 2017 Share Posted September 28, 2017 1 hour ago, Colonel_Panic said: Do I need to do something to actually get responseCodes when the account is locked? My onResponseCode function is never being called, so it just sits looking at the login screen with the "Your account has been disabled" message. Yeah you have to code the response codes. Theres 25of them but only like 7 of them are importsnt Quote Link to comment Share on other sites More sharing options...
Colonel_Panic Posted September 28, 2017 Share Posted September 28, 2017 12 minutes ago, Juggles said: Yeah you have to code the response codes. Theres 25of them but only like 7 of them are importsnt No I mean onResponseCode itself is never being called. I have a massive switch statement with all 25 included, but onResponseCode is never being called so the switch statement is never hit. Quote Link to comment Share on other sites More sharing options...
scape Posted September 28, 2017 Share Posted September 28, 2017 (edited) 4 minutes ago, Colonel_Panic said: No I mean onResponseCode itself is never being called. I have a massive switch statement with all 25 included, but onResponseCode is never being called so the switch statement is never hit. Same problem with mine. Looks like response codes are never called during the event, only after the event has been executed. Had to make it extend MethodProvider and no longer event and run it like a script. Edited September 28, 2017 by scape Quote Link to comment Share on other sites More sharing options...
Butters Posted September 30, 2017 Share Posted September 30, 2017 On 9/29/2017 at 12:38 AM, Colonel_Panic said: No I mean onResponseCode itself is never being called. I have a massive switch statement with all 25 included, but onResponseCode is never being called so the switch statement is never hit. On 9/29/2017 at 12:42 AM, scape said: Same problem with mine. Looks like response codes are never called during the event, only after the event has been executed. Had to make it extend MethodProvider and no longer event and run it like a script. This was giving me a huge headache onResponseCode() gets called at the end of loop iteration. Quote Link to comment Share on other sites More sharing options...
Juggles Posted October 1, 2017 Share Posted October 1, 2017 18 hours ago, nosepicker said: This was giving me a huge headache onResponseCode() gets called at the end of loop iteration. Added the breakcondition for WalkingEvent and it seemed to fix the not logging issue for that. But sometimes I find accounts not logging back in and when i log in, they're at the dock fishing lobster so im not sure what would cause that to not log back in. So not sure what they could be getting stuck in to not call LoginEvent Quote Link to comment Share on other sites More sharing options...
Elysiano Posted November 23, 2017 Share Posted November 23, 2017 On 9/28/2017 at 11:38 PM, Colonel_Panic said: No I mean onResponseCode itself is never being called. I have a massive switch statement with all 25 included, but onResponseCode is never being called so the switch statement is never hit. On 9/28/2017 at 11:42 PM, scape said: Same problem with mine. Looks like response codes are never called during the event, only after the event has been executed. Had to make it extend MethodProvider and no longer event and run it like a script. On 9/30/2017 at 10:33 AM, nosepicker said: This was giving me a huge headache onResponseCode() gets called at the end of loop iteration. I got exactly the same problem, how did you guys fix it? Everything is working except for the response method Quote Link to comment Share on other sites More sharing options...
gangsthurh Posted March 15, 2018 Share Posted March 15, 2018 (edited) hey boyz, i wrote an update to this login handler that fixes it for the march15 patch (is stopping people at the "click here to play" button) Spoiler //https://osbot.org/forum/topic/109560-a-simple-login-handler/ //https://osbot.org/forum/topic/109560-a-simple-login-handler/ //patched version march15 2018 package bot.steven.LDirectives; import java.awt.Color; import org.osbot.rs07.api.ui.RS2Widget; import org.osbot.rs07.constants.ResponseCode; import org.osbot.rs07.event.Event; import org.osbot.rs07.input.mouse.RectangleDestination; import org.osbot.rs07.listener.LoginResponseCodeListener; import org.osbot.rs07.script.Script; import org.osbot.rs07.utility.ConditionalSleep; public final class LoginEvent extends Event implements LoginResponseCodeListener { private String username, password; public LoginEvent(Script script) { this.script = script; } Script script; public void setUsername(final String username) { this.username = username; } public void setPassword(final String password) { this.password = password; } public final int execute() throws InterruptedException { if (getClient().isLoggedIn() && getLobbyButton() == null) { setFinished(); } else if (getLobbyButton() != null) { clickLobbyButton(); } else if (isOnWorldSelectorScreen()) { cancelWorldSelection(); } else { login(); } return random(100, 150); } private boolean isOnWorldSelectorScreen() { return getColorPicker().isColorAt(50, 50, Color.BLACK); } private void cancelWorldSelection() { if (getMouse().click(new RectangleDestination(getBot(), 712, 8, 42, 8))) { new ConditionalSleep(3000) { public boolean condition() throws InterruptedException { return !isOnWorldSelectorScreen(); } }.sleep(); } } private void login() { switch (getClient().getLoginUIState()) { case 0: clickExistingUsersButton(); break; case 1: clickLoginButton(); break; case 2: enterUserDetails(); break; } } private void clickExistingUsersButton() { getMouse().click(new RectangleDestination(getBot(), 400, 280, 120, 20)); } private void clickLoginButton() { getMouse().click(new RectangleDestination(getBot(), 240, 310, 120, 20)); } private void enterUserDetails() { if (!getKeyboard().typeString(username)) { setFailed(); return; } if (!getKeyboard().typeString(password)) { setFailed(); return; } new ConditionalSleep(10_000) { public boolean condition() throws InterruptedException { return getLobbyButton() != null; } }.sleep(); } private void clickLobbyButton() { if (getLobbyButton().interact()) { new ConditionalSleep(10_000) { public boolean condition() throws InterruptedException { return getLobbyButton() == null; } }.sleep(); } } private RS2Widget getLobbyButton() { try{ return script.widgets.get(378,76);//(gangsthurh) changed code here //return getWidgets().getWidgetContainingText("CLICK HERE TO PLAY"); }catch(NullPointerException n){ return null; } } public final void onResponseCode(final int responseCode) throws InterruptedException { if(ResponseCode.isDisabledError(responseCode)) { log("Login failed, account is disabled"); setFailed(); return; } if(ResponseCode.isConnectionError(responseCode)) { log("Connection error, attempts exceeded"); setFailed(); return; } } } Edited March 15, 2018 by gangsthurh spoilerthing 1 Quote Link to comment Share on other sites More sharing options...