Jump to content
Frequently Asked Questions
  • Are you not able to open the client? Try following our getting started guide
  • Still not working? Try downloading and running JarFix
  • Help! My bot doesn't do anything! Enable fresh start in client settings and restart the client
  • How to purchase with PayPal/OSRS/Crypto gold? You can purchase vouchers from other users
  • Determine whether a break is active


    Diggington

    Recommended Posts

    Hello,

    Is there a built in way to determine whether the inbuilt break functionality is currently active? I tried using ScriptManager.State to check if it was Paused, but it didn't seem to work. Could anyone point me to the relevant docs pls

    Link to comment
    Share on other sites

    Hi, depending on what exactly You would like to do during that, I think the best option would be to replace script's BreakSolver with Your own implementation.

    I made a simple class that extends DreamBot's BreakSolver and whenever a break appears, I just fire my own code before default operations.

    Here's how it looks like

    import org.dreambot.api.randoms.BreakSolver;
    import org.dreambot.api.utilities.Logger;
    
    public class BreakDetector extends BreakSolver {
    
    	@Override
    	public void onStart() {
    		if (this.getMinimumRest() > 5 * 60) { // breaks longer than 5 minutes
    			Logger.log("Going on a break!");
    		}
    		super.onStart();
    	}
    
    	@Override
    	public void onFinish() {
    		if (this.getMinimumRest() > 5 * 60) {
    			Logger.log("Finished break!");
    		}
    		super.onFinish();
    	}
    
    	@Override
    	public String getEventString() {
    		return "breakDetector";
    	}
    
    }

     

    Then in the script's onStart method I do this

    this.getRandomManager().disableSolver(RandomEvent.BREAK);
    this.getRandomManager().registerSolver(new BreakDetector());
    this.getRandomManager().enableSolver("breakDetector");

     

    For more information, refer to BreakSolver JavaDoc - https://dreambot.org/javadocs/org/dreambot/api/randoms/BreakSolver.html

    Edited by prechcik
    Link to comment
    Share on other sites

    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
    ×
    ×
    • Create New...

    Important Information

    We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.