Jump to content

Logout sleep


Recommended Posts

Posted (edited)
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
Posted
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)

Posted
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 

 

Posted (edited)
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
  • Like 2
  • Boge 2

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...