Jump to content
View in the app

A better way to browse. Learn more.

OSBot :: 2007 OSRS Botting

A full-screen app on your home screen with push notifications, badges and more.

To install this app on iOS and iPadOS
  1. Tap the Share icon in Safari
  2. Scroll the menu and tap Add to Home Screen.
  3. Tap Add in the top-right corner.
To install this app on Android
  1. Tap the 3-dot menu (⋮) in the top-right corner of the browser.
  2. Tap Add to Home screen or Install app.
  3. Confirm by tapping Install.

A Simple Login Handler

Featured Replies

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 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.

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 hour ago, Juggles said:

Maybe we should revert to spoilers when posting code 

Ok maybe next time

  • 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);
    }

 

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 :D, idk why i didn't think of doing it in that way lol

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.

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 

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.  

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 by scape

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 :D onResponseCode() gets called at the end of loop iteration. 

18 hours ago, nosepicker said:

 

This was giving me a huge headache :D 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 

  • 1 month later...
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 :D 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 :( 

  • 3 months later...

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 by gangsthurh
spoilerthing

Create an account or sign in to comment

Recently Browsing 0

  • No registered users viewing this page.

Account

Navigation

Search

Configure browser push notifications

Chrome (Android)
  1. Tap the lock icon next to the address bar.
  2. Tap Permissions → Notifications.
  3. Adjust your preference.
Chrome (Desktop)
  1. Click the padlock icon in the address bar.
  2. Select Site settings.
  3. Find Notifications and adjust your preference.