September 27, 20178 yr 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; }
September 27, 20178 yr 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.
September 27, 20178 yr 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
September 27, 20178 yr 1 hour ago, Juggles said: Maybe we should revert to spoilers when posting code Ok maybe next time
September 27, 20178 yr Author 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); }
September 27, 20178 yr 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
September 28, 20178 yr 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.
September 28, 20178 yr 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
September 28, 20178 yr 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.
September 28, 20178 yr 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, 20178 yr by scape
September 30, 20178 yr 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.
October 1, 20178 yr 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
November 23, 20178 yr 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
March 15, 20187 yr 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, 20187 yr by gangsthurh spoilerthing
Create an account or sign in to comment