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.

Hop world after logging out

Featured Replies

alright, I think I've found something that I will try out tomorrow :)

Let me know if you do :)

  • Author

I tried doing this to disable aut-login but it didn't disable it:

 this.bot.getRandomExecutor().registerHook(new RandomBehaviourHook(RandomEvent.AUTO_LOGIN)
        {
            public String getName() {
                return super.getName();
            }
 
            public boolean shouldActivate()
            {
                return false;
            }
        });

it would still log me in when logged out of the game

I tried doing this to disable aut-login but it didn't disable it:

 this.bot.getRandomExecutor().registerHook(new RandomBehaviourHook(RandomEvent.AUTO_LOGIN)
        {
            public String getName() {
                return super.getName();
            }
 
            public boolean shouldActivate()
            {
                return false;
            }
        });

it would still log me in when logged out of the game

You cannot disable it and put it on the sdn, custom log in methods are prohibited as Alek said sometime before :P

  • Author

You cannot disable it and put it on the sdn, custom log in methods are prohibited as Alek said sometime before :P

It's going to stay private :)

It's going to stay private smile.png

		getBot().getRandomExecutor().registerHook(new RandomBehaviourHook(RandomEvent.AUTO_LOGIN) {
			@Override
			public boolean shouldActivate() {
					return false;
				}
			}
		);

It's going to stay private smile.png

In that case...

 

You firstly need to remove the auto log in event and then just register a new one when you need it.

Edited by Vilius

  • Author

I translated this method from another bot's api to osbot's api:

import org.osbot.rs07.api.Client;
import org.osbot.rs07.api.ui.RS2Widget;
import org.osbot.rs07.input.mouse.RectangleDestination;
import org.osbot.rs07.script.MethodProvider;
import org.osbot.rs07.script.RandomBehaviourHook;
import org.osbot.rs07.script.RandomEvent;
import org.osbot.rs07.script.Script;

import java.awt.*;

public class Hopping {

    static Script script;

    public static final int[] WORLDS = {1,2,3,4,5,6,8,9,10,11,12,13,14,16,17,18,19,20,21,
            22,25,26,27,28,29,30,33,34,35,36,37,38,41,42,43,44,45,46,49,50,51,52,53,54,57,58,
            59,60,61,62,65,66,67,68,69,70,73,74,75,76,77,78,81,82,83,84,93,94};
    private static final int[] FREE_WORLDS = {8,16,81,82,83,84,93,94};
    private static final int[] PVP_WORLDS = {25,37,18,65,57,52,45};
    private static final int[] POPULAR_WORLDS = {1,81};

    private static final Color LOGIN_SCREEN = new Color(255,255,0);
    private static final Color WORLD_SELECT = new Color(0, 0, 0);
    private static final Color NEW_USER = new Color(255,255,255);

    private static boolean quickLogout = false;
    private static boolean excludeFree = true;
    private static boolean excludePVP = true;
    private static boolean excludePopular = true;

    public static boolean hop() throws InterruptedException {
        //Hops to a random world
        if(!logout()){
            return false;
        }
        openWorldSelect();
        int world = 0;
        //Make sure world is valid
        while(!isValid(world)
                || excludeFree
                && isFree(world)
                || excludePVP
                && isPVP(world)
                || excludePopular
                && isPopular(world)){
            world = WORLDS[MethodProvider.random(0, 67)];
        }
        selectWorld(world);
        openLoginInfo();
        return login()
                && getCurrentWorld() == world;
    }
    public static boolean hop(int[] exclusions) throws InterruptedException {
        //Hops to a random world excluding exclusions
        if(!logout()){
            return false;
        }
        openWorldSelect();
        int world = 0;
        //Make sure world is valid
        while(!isValid(world)
                || excludeFree
                && isFree(world)
                || excludePVP
                && isPVP(world)
                || excludePopular
                && isPopular(world)
                || isExclusion(exclusions, world)){
            world = WORLDS[MethodProvider.random(0, 67)];
        }
        selectWorld(world);
        openLoginInfo();
        return login()
                && getCurrentWorld() == world;
    }
    public static boolean hop(int world) throws InterruptedException {
        //Hop to a specific world
        if(!logout()){
            return false;
        }
        while(!isValid(world)
                || excludeFree
                && isFree(world)
                || excludePVP
                && isPVP(world)
                || excludePopular
                && isPopular(world)){
            world = WORLDS[MethodProvider.random(0, 67)];
        }
        openWorldSelect();
        selectWorld(world);
        openLoginInfo();
        return login()
                && getCurrentWorld() == world;
    }

    public static boolean logout() throws InterruptedException {
        try {
            while (script.getClient().getLoginState() == Client.LoginState.LOGGED_IN
                    && !script.myPlayer().isUnderAttack()) {
                if(script.getLogoutTab().logOut()){
                    long time = System.currentTimeMillis();
                    while ((System.currentTimeMillis() - 1500L < time) &&
                            (!isOnLoginscreen())) {
                        MethodProvider.sleep(250L);
                    }
                }
        }
        } catch (Exception e) {

        }
        return isOnLoginscreen();
    }
    private static boolean selectWorld(int world) throws InterruptedException{
        //Selects the world provided
        Rectangle r = getWorldRectangle(world);
        while(isOnWorldSelect()){
            script.getMouse().click(new RectangleDestination(script.getBot(), (int) r.getX(), (int) r.getY(), (int) (r.getX() + r.getWidth()), (int) (r.getY() + r.getHeight())));
            MethodProvider.sleep(MethodProvider.random(500,750));
        }
        return !isOnWorldSelect();
    }
    private static boolean openWorldSelect() throws InterruptedException{
        while(!isOnWorldSelect()){
            script.getMouse().click(new RectangleDestination(script.getBot(), 12, 466, 98, 489));
            MethodProvider.sleep(MethodProvider.random(500,750));
        }
        return isOnWorldSelect();
    }
    private static void openLoginInfo() throws InterruptedException{
        while(!isOnWorldSelect()
                && !isOnLoginInfo()
                && script.getClient().getLoginState() != Client.LoginState.LOGGED_IN){
            if(!isOnWarningScreen()
                    && !isOnNewUser()){
                script.getMouse().click(new RectangleDestination(script.getBot(), 400, 275, 505, 300));
            }else if(isOnWarningScreen()){
                script.getMouse().click(new RectangleDestination(script.getBot(), 245,308,360,335));
            }else{
                script.getMouse().click(new RectangleDestination(script.getBot(), 329, 310, 443, 330));
            }
            MethodProvider.sleep(300);
        }
    }
    public static boolean login() throws InterruptedException {
        while(script.getClient().getLoginState() != Client.LoginState.LOGGED_IN){
            script.getBot().getRandomExecutor().registerHook(new RandomBehaviourHook(RandomEvent.AUTO_LOGIN) {
                @Override
                public boolean shouldActivate() {
                    return super.shouldActivate();
                }
            });
            MethodProvider.sleep(MethodProvider.random(500,750));
        }
        return script.getClient().getLoginState() == Client.LoginState.LOGGED_IN;
    }

    public static int worldAsInt(int world){
        for(int i = 0 ; i < WORLDS.length; i++)
            if(world == WORLDS[i]) return i;
        return 0;
    }

    public static String getState(){
        //Return the current login state
        if(script.getClient().getLoginState() == Client.LoginState.LOGGED_IN)
            return "Ingame";
        if(script.getClient().getLoginState() == Client.LoginState.LOGGED_IN)
            return "Welcome Screen";
        if(isOnLoginscreen())
            return "Login Screen";
        if(isOnWorldSelect())
            return "World Select";
        if(isOnWarningScreen())
            return "Warning Screen";
        if(isOnLoginInfo())
            return "Login Info";
        if(isOnNewUser())
            return "New User";
        return "Unknown";
    }
    private static boolean isOnLoginscreen(){
        return colorsMatch(script.getColorPicker().colorAt(386, 250), LOGIN_SCREEN);
    }
    private static boolean isOnNewUser(){
        return colorsMatch(script.getColorPicker().colorAt(383, 323), NEW_USER);
    }
    private static boolean isOnWorldSelect(){
        return (colorsMatch(script.getColorPicker().colorAt(100, 100), WORLD_SELECT)) &&
                (colorsMatch(script.getColorPicker().colorAt(600, 450), WORLD_SELECT)) &&
                (colorsMatch(script.getColorPicker().colorAt(600, 50), WORLD_SELECT)) &&
                (colorsMatch(script.getColorPicker().colorAt(100, 450), WORLD_SELECT));
    }
    private static boolean isOnLoginInfo(){
        return colorsMatch(script.getColorPicker().colorAt(275, 280), new Color(255,255,255));
    }
    private static boolean isOnWarningScreen(){
        return colorsMatch(script.getColorPicker().colorAt(408, 201), new Color(255,255,0));
    }

    public static boolean isValid(int world){
        for(int i : WORLDS){
            if(world == i){
                return true;
            }
        }
        return false;
    }
    private static boolean isFree(int world){
        for(int i : FREE_WORLDS){
            if(world == i){
                return true;
            }
        }
        return false;
    }
    private static boolean isPVP(int world){
        for(int i : PVP_WORLDS){
            if(world == i){
                return true;
            }
        }
        return false;
    }
    private static boolean isPopular(int world){
        for(int i : POPULAR_WORLDS){
            if(world == i){
                return true;
            }
        }
        return false;
    }
    private static boolean isExclusion(int[] exclusions, int world){
        for(int i : exclusions){
            if(i == world){
                return true;
            }
        }
        return false;
    }

    public static void paintRects(Graphics g){
        if(getState().equals("World Select")){
            g.setColor(Color.green);
            for(int world : WORLDS){
                boolean draw = true;
                if(!isValid(world)) draw = false;
                if(excludePVP && isPVP(world)) draw = false;
                if(excludeFree && isFree(world)) draw = false;
                if(excludePopular && isPopular(world)) draw = false;
                if(draw){
                    Rectangle r = getWorldRectangle(world);
                    g.drawRect(r.x, r.y, r.width, r.height);
                }
            }
        }
    }
    private static Rectangle getRectangle(int index){
        int x = ((int) ((Math.floor(index) / 17) % 4) * 93) + 205;
        int y = ((int) (Math.ceil(index) % 17) * 24) + 61;
        return new Rectangle(x,y,81,18);
    }
    private static Rectangle getWorldRectangle(int world){
        for(int i = 0; i < WORLDS.length; i++){
            if(WORLDS[i] == world){
                return getRectangle(i);
            }
        }
        return new Rectangle(0,0,0,0);
    }
    public static int getCurrentWorld(){
        RS2Widget child = script.getWidgets().get(550, 2);
        if(child == null) return 0;
        return Integer.parseInt(child.getMessage().split(" ")[4])%300;
        //return Game.getCurrentWorld() % 300;
    }

    private static boolean colorsMatch(Color col1, Color col2){
        return (col1.getRed() == col2.getRed()) &&
                (col1.getGreen() == col2.getGreen()) &&
                (col1.getBlue() == col2.getBlue());
    }

    public static void setExcludeFree(boolean enabled){
        excludeFree = enabled;
    }
    public static void setExcludePVP(boolean enabled){
        excludePVP = enabled;
    }
    public static void setExcludePopular(boolean enabled){
        excludePopular = enabled;
    }
    public static void setQuickLogout(boolean enabled){
        quickLogout = enabled;
    }
}

but it gives some errors:

java.lang.NullPointerException
	at Hopping.isOnLoginscreen(Hopping.java:183)
	at Hopping.logout(Hopping.java:112)
	at Hopping.hop(Hopping.java:33)
	at WorldHopper.execute(WorldHopper.java:44)
	at AceGDK.onLoop(AceGDK.java:251)
	at org.osbot.rs07.event.ScriptExecutor$InternalExecutor.run(yg:194)
	at java.lang.Thread.run(Unknown Source)

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.