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.

How to sleep while game is loading?

Featured Replies

I want my script to sleep after hoppings worlds, I'm having problems when my onLoop tries to define objects from the game, before it is properly loaded. Which is causing some issues. It works if i add a static sleep, but something like a conditional sleep would make it a lot more reliable and faster.  I tried using getGameState(), but it's always returning LOGGED_IN. Is there something that I've missed?

	@Override
	public int onLoop() throws InterruptedException {
		String state = getClient().getGameState().toString();
		if(state != "LOADING" && state != "HOPPING") {
			npc = getNpcs().closest(npcName);
	
			if(!getStore().isOpen()) {
				if(hasItems()) {
					if(area(npcName).contains(myPlayer())) {
						if(npc != null) {
							if(npc.exists()) {
								npc.interact("Trade");
								new Sleep(() -> getStore().isOpen(), 2000).sleep();
								buyOrSell();
							}
						} else {
							log("Npc is null");
						}
					} else {
						walkTo(npcName);
					}
	
				} else {
					getItems();
				}
			} else {
				buyOrSell();
			}
		} else {
			log("State: " + state);
		}
		return 10;
	}

 

The proper way to compare strings is with .equals()

if(!"LOADING".equals(state) && !"HOPPING".equals(state)) {

You could also just compare directly to the enum

Client.GameState state = getClient().getGameState();
if(!Client.GameState.LOADING.equals(state) && !Client.GameState.HOPPING.equals(state)) {

There is a conditional sleep class: https://osbot.org/api/org/osbot/rs07/utility/ConditionalSleep2.html

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.