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.

[Snippet request] Conditional sleep until login and welcome screen are completed

Featured Replies

Does anyone know how to implement this? Scripts seem to get a couple of 'onLoop's off in between the client solving the login screen event and detecting the welcome screen event. The welcome screen seems to cause weird bugs in the initial part of a script if you need to set up config based on what the player can see.

You could sleep when bot.getRandomExecutor().forEvent(RandomEvent.WELCOME_SOLVER).shouldActivate() == true, assuming the widget is actually visible when this happens.

if (!getClient().isLoggedIn()) {

    //Conditional sleep until getClient().isLoggedIn()

}

Edit: Just wanna add that a conditional sleep may not be the best for this, eg if it's in onloop you can just do:

if (!getClient().isLoggedIn()) {
    return 1000;
}

Edited by Bobrocket

  • Author
if (!getClient().isLoggedIn()) {

    //Conditional sleep until getClient().isLoggedIn()

}

Edit: Just wanna add that a conditional sleep may not be the best for this, eg if it's in onloop you can just do:

if (!getClient().isLoggedIn()) {
    return 1000;
}

 

 

You could sleep when bot.getRandomExecutor().forEvent(RandomEvent.WELCOME_SOLVER).shouldActivate() == true, assuming the widget is actually visible when this happens.

 

Thanks for your help. By combining both of these checks I was able to create a snippet that solves the problem. Note that RandomSolver#shouldActivate crashes with a NullPointerException if you call it for the WELCOME_SOLVER event when you're already logged in. This is probably a bug - and is the reason for the try - catch below.

if (!doneOnReady) {
            boolean loggedIn = bot.getClient().isLoggedIn();
            boolean inWelcomeScreen;
            try {
                inWelcomeScreen = bot.getRandomExecutor().forEvent(RandomEvent.WELCOME_SOLVER).shouldActivate();
            }
            catch (NullPointerException e) {
                inWelcomeScreen = false;
            }

            if (loggedIn && inWelcomeScreen == false) {
                onReady();
                doneOnReady = true;
            }
            else {
                return 100;
            }
        }

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.