April 19, 20187 yr 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; } }
May 7, 20187 yr 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);
May 24, 20187 yr I have a problem with the script, I try to execute it and when you press "Login" it sends the following error: Error
July 26, 20187 yr 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, 20187 yr by Pegasus
August 14, 20187 yr How can I call the login handler again when i get returned to the login screen for some reason?
November 26, 20187 yr 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.
December 12, 20187 yr 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
December 13, 20187 yr 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, 20187 yr by JoRouss
February 25, 20196 yr 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, 20196 yr by Pegasus
February 25, 20196 yr 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?
February 25, 20196 yr 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 ?
February 25, 20196 yr 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
February 26, 20196 yr 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, 20196 yr by Pegasus
May 25, 20196 yr Guys, did you find out, how to get onResponseCode ? Edited May 26, 20196 yr by Michal Ziak
Create an account or sign in to comment