Jump to content

Logout sleep


AngryKey
 Share

Recommended Posts

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
Link to comment
Share on other sites

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)

Link to comment
Share on other sites

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 

 

Link to comment
Share on other sites

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
Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

 Share

  • Recently Browsing   0 members

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