GPSwap Posted April 19, 2018 Posted April 19, 2018 On 15/03/2018 at 9:33 PM, gangsthurh said: 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) Hide contents //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; } } } you dont need to change the getwidgets code you can just add the try/catch and it works fine Spoiler private RS2Widget getLobbyButton() { try{ return getWidgets().getWidgetContainingText("CLICK HERE TO PLAY"); }catch(NullPointerException n){ return null; } }
Zor Posted May 7, 2018 Posted May 7, 2018 total idiot question but how can i call this login from another class?
Juggles Posted May 7, 2018 Posted May 7, 2018 7 minutes ago, Zor said: total idiot question but how can i call this login from another class? LoginEvent loginEvent = new LoginEvent(username, password); getBot().addLoginListener(loginEvent); execute(loginEvent); 1
trainux Posted May 24, 2018 Posted May 24, 2018 I have a problem with the script, I try to execute it and when you press "Login" it sends the following error: Error
Pegasus Posted July 26, 2018 Posted July 26, 2018 (edited) When I run it, it shows NullPointerException immediately. Script doesn't start if account hasn't logined / I turned off client auto login? onstart not being called before user is logged Uncaught exception! java.lang.NullPointerException at org.osbot.rs07.event.ScriptExecutor$3.run(kl:211) at java.awt.event.InvocationEvent.dispatch(Unknown Source) at java.awt.EventQueue.dispatchEventImpl(Unknown Source) at java.awt.EventQueue.access$500(Unknown Source) at java.awt.EventQueue$3.run(Unknown Source) at java.awt.EventQueue$3.run(Unknown Source) at java.security.AccessController.doPrivileged(Native Method) at java.security.ProtectionDomain$JavaSecurityAccessImpl.doIntersectionPrivilege(Unknown Source) at java.awt.EventQueue.dispatchEvent(Unknown Source) at java.awt.EventDispatchThread.pumpOneEventForFilters(Unknown Source) at java.awt.EventDispatchThread.pumpEventsForFilter(Unknown Source) at java.awt.EventDispatchThread.pumpEventsForHierarchy(Unknown Source) at java.awt.EventDispatchThread.pumpEvents(Unknown Source) at java.awt.EventDispatchThread.pumpEvents(Unknown Source) at java.awt.EventDispatchThread.run(Unknown Source) Edited July 26, 2018 by Pegasus
Zummy Posted August 14, 2018 Posted August 14, 2018 How can I call the login handler again when i get returned to the login screen for some reason?
frixxer Posted November 26, 2018 Posted November 26, 2018 When I try to use this handler, It works when on logging for the first time, but whenever I try to log in again after that, nothing happens. Can someone help me out pls!!! I followed all of the instructions.
dormic Posted December 12, 2018 Posted December 12, 2018 On 8/14/2018 at 8:01 PM, Zummy said: How can I call the login handler again when i get returned to the login screen for some reason? By calling the same method again
JoRouss Posted December 13, 2018 Posted December 13, 2018 (edited) I there a way I can get the password from Explv bot manager? Or do I have to type it as string and compile the jar again? EDIT: I noticed by right clicking on my configuration and then "Show command", I see the email and pass. I just don't know how to retreive it in my script. Edited December 13, 2018 by JoRouss
Pegasus Posted February 25, 2019 Posted February 25, 2019 (edited) getBot().isLoaded() is not working @ Override public final int execute() throws InterruptedException { if (!getBot().isLoaded()) { return 1000; } else if (getClient().isLoggedIn() && getLobbyButton() == null) { getBot().getScriptExecutor().resume(); setFinished(); } else if (!getBot().getScriptExecutor().isPaused()) { getBot().getScriptExecutor().pause(); } else if (getLobbyButton() != null) { clickLobbyButton(); } else if (isOnWorldSelectorScreen()) { cancelWorldSelection(); } else if (!isPasswordEmpty()) { clickCancelLoginButton(); } else { login(); } return random(100, 150); } I got this NPE : java.lang.NullPointerException at org.osbot.rs07.api.Widgets.getWidgetContainingText(tl:727) at com.iaox.farmer.handlers.LoginEvent.getLobbyButton(LoginEvent.java:140) at com.iaox.farmer.handlers.LoginEvent.execute(LoginEvent.java:37) at org.osbot.rs07.event.EventExecutor$2.run(zj:230) at java.util.concurrent.Executors$RunnableAdapter.call(Unknown Source) at java.util.concurrent.FutureTask.run(Unknown Source) at java.util.concurrent.ThreadPoolExecutor.runWorker(Unknown Source) at java.util.concurrent.ThreadPoolExecutor$Worker.run(Unknown Source) at java.lang.Thread.run(Unknown Source) Edited February 25, 2019 by Pegasus
hreyvirtue Posted February 25, 2019 Posted February 25, 2019 27 minutes ago, Pegasus said: getBot().isLoaded() is not working @ Override public final int execute() throws InterruptedException { if (!getBot().isLoaded()) { return 1000; } else if (getClient().isLoggedIn() && getLobbyButton() == null) { getBot().getScriptExecutor().resume(); setFinished(); } else if (!getBot().getScriptExecutor().isPaused()) { getBot().getScriptExecutor().pause(); } else if (getLobbyButton() != null) { clickLobbyButton(); } else if (isOnWorldSelectorScreen()) { cancelWorldSelection(); } else if (!isPasswordEmpty()) { clickCancelLoginButton(); } else { login(); } return random(100, 150); } I got this NPE : java.lang.NullPointerException at org.osbot.rs07.api.Widgets.getWidgetContainingText(tl:727) at com.iaox.farmer.handlers.LoginEvent.getLobbyButton(LoginEvent.java:140) at com.iaox.farmer.handlers.LoginEvent.execute(LoginEvent.java:37) at org.osbot.rs07.event.EventExecutor$2.run(zj:230) at java.util.concurrent.Executors$RunnableAdapter.call(Unknown Source) at java.util.concurrent.FutureTask.run(Unknown Source) at java.util.concurrent.ThreadPoolExecutor.runWorker(Unknown Source) at java.util.concurrent.ThreadPoolExecutor$Worker.run(Unknown Source) at java.lang.Thread.run(Unknown Source) What does your script look like? Does it just execute the login script immediately after the client begins launching?
Pegasus Posted February 25, 2019 Posted February 25, 2019 1 hour ago, hreyvirtue said: What does your script look like? Does it just execute the login script immediately after the client begins launching? that script won't work. How can the client get login before login event execute ?
hreyvirtue Posted February 25, 2019 Posted February 25, 2019 9 minutes ago, Pegasus said: that script won't work. How can the client get login before login event execute ? If the client isn't logged in, then the login event executes, that's the point of that script Set it on loop and adds sleeps if you need to
Pegasus Posted February 26, 2019 Posted February 26, 2019 (edited) 16 hours ago, hreyvirtue said: If the client isn't logged in, then the login event executes, that's the point of that script Set it on loop and adds sleeps if you need to I mean login event execute is not working. It is because getBot().isLoaded() is not working it return true even the client is still downloading data from official game. Edited February 26, 2019 by Pegasus
Michal Ziak Posted May 25, 2019 Posted May 25, 2019 (edited) Guys, did you find out, how to get onResponseCode ? Edited May 26, 2019 by Michal Ziak