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
  • Try asking for help in the chatbox
  • Timer


    kamilo
     Share

    Recommended Posts

    Creating my own break handler, so since i have a Timer timer = new Timer() running i was wondering how could pause this timer during the break; ofcourse i would manually disable login etc.. but i also want to pause/resume this Timer from dreambot api, but nothing in the api has a pause button etc..

     

    can someone help

    Link to comment
    Share on other sites

    save the remaining in a double... stop the timer.. create a new timer with the double amount.

    //Start a timer
    Timer timer = new Timer(1000); //1 second
    
    //Pause
    double remaining = timer.remaining(); //milliseconds
    timer = null;
    
    //Resume
    timer = new Timer(remaining);

     

    Link to comment
    Share on other sites

    7 minutes ago, Defiled said:

    save the remaining in a double... stop the timer.. create a new timer with the double amount.

    //Start a timer
    Timer timer = new Timer(1000); //1 second
    
    //Pause
    double remaining = timer.remaining(); //milliseconds
    timer = null;
    
    //Resume
    timer = new Timer(remaining);

     

    That's a cool trick. I'm sure I'll make use of this, thanks

    Link to comment
    Share on other sites

    10 hours ago, Defiled said:

    save the remaining in a double... stop the timer.. create a new timer with the double amount.

    //Start a timer
    Timer timer = new Timer(1000); //1 second
    
    //Pause
    double remaining = timer.remaining(); //milliseconds
    timer = null;
    
    //Resume
    timer = new Timer(remaining);

     

    why are u doing new Timer(1000) instead of new Timer(); does it make a difference

    or does it set the increment in milliseconds

    Link to comment
    Share on other sites

    35 minutes ago, kamilo said:

    why are u doing new Timer(1000) instead of new Timer(); does it make a difference

    or does it set the increment in milliseconds

    1000 is the parameter for the countdown amount in milliseconds.. so if you set it to 1000 it'll count 1 second then it'll return finished() 

    Link to comment
    Share on other sites

    19 minutes ago, Defiled said:

    1000 is the parameter for the countdown amount in milliseconds.. so if you set it to 1000 it'll count 1 second then it'll return finished() 

    got it!, what if i start a timer counting upwards, just new Timer();, for checking how long the script is run for

    how would i go about pausing that, cuz the code seems to be like a stop watch and counts down, but i want to count upwards (duration of the sript running), then pause (for break so its not included in total time ran), then resume choosing my own conditions

    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
     Share

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