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.

Logout sleep

Featured Replies

		NPC monster=this.npcs.closest("boss");
		if(monster!=null&&!myPlayer().isUnderAttack()){
			this.logoutTab.logOut();//logout
		}

hello!

but  will automatically login

I want it to wait for a while to login

what should I do.

Edited by AngryKey

  • Author
Just now, Charlotte said:

sleep?

custom login handler?

Any method can be! help!!!!

2 hours ago, AngryKey said:

Any method can be! help!!!!

I’m unclear what you are asking for, but from what I can gather is that you want to logout if a boss exists and you’re not under attack, wait, then login again?

For login I would use a custom login handler to handle the event. There’s an example somewhere around here, just do a quick search.

For the wait set a timer. You can store System.currentTimeMillis on logout. Then on the loop check for the required gap. If ( System.currentTimeMillis - storedTime > waitTime ) then login.

 

Edited by jca

  • Author
17 minutes ago, jca said:

I’m unclear what you are asking for, but from what I can gather is that you want to logout if a boss exists and you’re not under attack, wait, then login again?

For login I would use a custom login handler to handle the event. There’s an example somewhere around here, just do a quick search.

For the wait set a timer. You can store System.currentTimeMillis on logout. Then on the loop check for the required gap. If ( System.currentTimeMillis - storedTime > waitTime ) then login.

 

1.Boss exists, I will logout
2.Wait 10 minutes // The script sleeps for 10 minutes while it is running.

3.login again

4.Attack other monsters

5.Boss exists, I will logout

(repeat)

13 minutes ago, AngryKey said:

1.Boss exists, I will logout
2.Wait 10 minutes // The script sleeps for 10 minutes while it is running.

3.login again

4.Attack other monsters

5.Boss exists, I will logout

(repeat)

make your own login handler. the client handler auto logs back in

 

launch the bot with command line arguments -norandoms 

 

16 minutes ago, AngryKey said:

1.Boss exists, I will logout
2.Wait 10 minutes // The script sleeps for 10 minutes while it is running.

3.login again

4.Attack other monsters

5.Boss exists, I will logout

(repeat)

Okay, what I said should do the trick. 

  • Author
On 10/16/2018 at 1:18 AM, Chris said:

make your own login handler. the client handler auto logs back in

 

launch the bot with command line arguments -norandoms 

 

Is there any other way?

46 minutes ago, AngryKey said:

Is there any other way?

Nah you need a custom login handler - @Explv posted one in the snippets section. That should be a good starting point.

4 hours ago, AngryKey said:

Is there any other way?

You could override the break manager, start a break when the boss exists, and finish the break after 10 minutes.

Example break manager:

 

import org.osbot.rs07.api.Client;
import org.osbot.rs07.script.RandomEvent;
import org.osbot.rs07.script.RandomSolver;
import org.osbot.rs07.script.ScriptManifest;

@ScriptManifest(author = "Explv", name = "Break Manager", info = "", version = 0.1, logo = "")
public class CustomBreakManager extends RandomSolver {

    private long breakDuration = -1;
    private long breakStartTime = -1;
    private boolean shouldLogout;

    public CustomBreakManager() {
        super(RandomEvent.BREAK_MANAGER);
    }

    public void startBreaking(final long breakDuration, final boolean shouldLogout) {
        this.breakDuration = breakDuration;
        this.breakStartTime = System.currentTimeMillis();
        this.shouldLogout = shouldLogout;
    }

    public long getBreakStartTime() {
        return breakStartTime;
    }

    @Override
    public boolean shouldActivate() {
        return breakDuration > 0 && !finishedBreaking();
    }

    public boolean finishedBreaking() {
        return System.currentTimeMillis() - breakStartTime >= breakDuration;
    }

    @Override
    public int onLoop() throws InterruptedException {
        if (shouldLogout && getClient().getLoginState() == Client.LoginState.LOGGED_IN) {
            if (getWidgets().closeOpenInterface() && getLogoutTab().logOut()) {
                return 1000;
            }
        }

        if (getMouse().isOnScreen()) {
            getMouse().moveOutsideScreen();
        }

        return 3000;
    }
}


Overriding (should be only done once, in onStart):
 

CustomBreakManager customBreakManager = new CustomBreakManager();
customBreakManager.exchangeContext(getBot());
getBot().getRandomExecutor().overrideOSBotRandom(customBreakManager);


Starting a break:
 

if (getNpcs().closest("Boss name") != null) {
    customBreakManager.startBreaking(TimeUnit.MINUTES.toMillis(10), true);
}

 

Edited by Explv

  • Author

perfect!!!!!!!

Edited by AngryKey

  • Author

thank!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!

thank

thankthank

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.