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

World hopping

Featured Replies

Hey I'm new to the bot scene and I'm currently struggling with a nullpointerexception.

Quote

    public static void HopWorldRandom() throws InterruptedException {
        int CurrentWorld = script.getWorlds().getCurrentWorld();
        int HoptoWorld = WORLDS[MethodProvider.random(WORLDS.length)];
        while(CurrentWorld == HoptoWorld) {
            HoptoWorld = WORLDS[MethodProvider.random(WORLDS.length)];
        }
        final int HoptoWorldfinal = HoptoWorld;
        script.log("Hopping to world: "+HoptoWorld);
        
        if(script.worlds.hop(HoptoWorld))
        new ConditionalSleep(MethodProvider.random(10000, 10000)) {
            @Override
            public boolean condition() throws InterruptedException {
                return CurrentWorld == HoptoWorldfinal;
            }
        }.sleep();
    }

It works for a couple of hours before I get a nullpointerexception and then it doesn't, any ideas?

WORLDS[] is simply an array of worlds to choose from when randomly hopping.

  • Author

I think I found a bug, I'm trying this now and so far so good:

Quote

    public static void HopWorldRandom() throws InterruptedException {
        int CurrentWorld = script.getWorlds().getCurrentWorld();
        int HoptoWorld = WORLDS[MethodProvider.random(WORLDS.length-1)];
        while(CurrentWorld == HoptoWorld) {
            HoptoWorld = WORLDS[MethodProvider.random(WORLDS.length-1)];
        }
        final int HoptoWorldfinal = HoptoWorld;
        script.log("Hopping to world: "+HoptoWorld);
        
        if(script.worlds.hop(HoptoWorld))
        new ConditionalSleep(MethodProvider.random(10000, 10000)) {
            @Override
            public boolean condition() throws InterruptedException {
                return CurrentWorld == HoptoWorldfinal;
            }
        }.sleep();
    }

 

Any tips on how to detect if I've hopped world?
return CurrentWorld == HoptoWorldfinal;
Is really slow.

  • Author

Solved it I think, here's the final code if someone needs it in the future:
 

Quote

    public static void HopWorldRandom() throws InterruptedException {
        int CurrentWorld = script.getWorlds().getCurrentWorld();
        int HoptoWorld = WORLDS[MethodProvider.random(WORLDS.length-1)];
        while(CurrentWorld == HoptoWorld) {
            HoptoWorld = WORLDS[MethodProvider.random(WORLDS.length-1)];
        }
        final int HoptoWorldfinal = HoptoWorld;
        script.log("Hopping to world: "+HoptoWorld);
        
        if(script.worlds.hop(HoptoWorld))
        new ConditionalSleep(10000, MethodProvider.random(1000, 2000)) {
            @Override
            public boolean condition() throws InterruptedException {
                return CurrentWorld == HoptoWorldfinal;
            }
        }.sleep();
    }

 

        new ConditionalSleep(MethodProvider.random(10000, 10000)) {
            @Override
            public boolean condition() throws InterruptedException {
                return CurrentWorld == HoptoWorldfinal;
            }
        }.sleep();

that will never work since you never update the values. do this instead

        new ConditionalSleep(MethodProvider.random(10000, 10000)) {
            @Override
            public boolean condition() throws InterruptedException {
                return script.getWorlds().getCurrentWorld() == HoptoWorldfinal;
            }
        }.sleep();

  • Author
10 minutes ago, Camaro said:

        new ConditionalSleep(MethodProvider.random(10000, 10000)) {
            @Override
            public boolean condition() throws InterruptedException {
                return CurrentWorld == HoptoWorldfinal;
            }
        }.sleep();

that will never work since you never update the values. do this instead

        new ConditionalSleep(MethodProvider.random(10000, 10000)) {
            @Override
            public boolean condition() throws InterruptedException {
                return script.getWorlds().getCurrentWorld() == HoptoWorldfinal;
            }
        }.sleep();

That is true, Thanks!

I don't think this will will solve the nullpointerexception error but it's a step in the right direction.

  • Author
ava.lang.NullPointerException
    at org.osbot.rs07.api.Worlds.iiiiIiiIIIIi(lf:97)
    at org.osbot.rs07.api.Worlds.IIIiiiiIIIii(lf:215)
    at org.osbot.rs07.api.Worlds.hop(lf:301)
    at MyPackage.task.MyMethodProvider.HopWorldRandom(MyMethodProvider.java:157)
    at MyMainClass.task.MyClass.execute(MyClass.java:78)
    at MyPackage.MyMainClass.onLoop(MyMainClass.java:43)
    at org.osbot.rs07.event.ScriptExecutor$InternalExecutor.run(ch:146)
    at java.lang.Thread.run(Unknown Source)

 

Edited by SatanicHammer

Create an account or sign in to comment

Recently Browsing 0

  • No registered users viewing this page.

Account

Navigation

Search

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.