Jump to content
UBot Underground

Best way to run a script every 5 minutes forever


Recommended Posts

As the headline says I need to run a script every 5 minutes.  Do I create an endless loop with a wait command that runs the script every 5 minutes, or is there some other way that is more preferred?

Link to post
Share on other sites

Hi.

 

The wait command is in seconds not minutes. And you should implement something to start and stop that script via a button. 

Is a lot more convenient for your users.

 

Please be aware that this currently doesn't work in Ubot V5. There is a bug how V5 handles threads. That has changed compared to V4. So the following example code is for V4 only.

 

ui button("STOP") {
     if($comparison(#TaskRunning, "=", 1)) {
        then {
            set(#stop, "true", "Global")
        }
        else {
        }
    }
}

 

define UpdateFirewall {
    set(#running, "true", "Global")
    set(#status, "Running", "Global")
    loop while($comparison(#running, "=", "true")) {
        set(#status, "Check IP", "Global")
        CheckIP()
        set(#status, 300, "Global")
        loop(300) {
            wait(1)
            CheckStop()
            decrement(#status)
        }
    }
}
 
 
 
define CheckStop {
    if($comparison(#stop, "=", "true")) {
        then {
            set(#status, 0, "Global")
            set(#running, "false", "Global")
            set(#stop, "false", "Global")
            stop script
        }
        else {
        }
    }
}
Link to post
Share on other sites

Thanks, good point on the button!

 

If you sell your bots, you should always use UI buttons. Instead of the normal run command. 

And in more complex bots you will also use a lot of define commands. And that works hand in hand with buttons as well. 

 

Dan

Link to post
Share on other sites

After several months and V5 still having bugs!  :(   Thanks Dan

 

...

 

Please be aware that this currently doesn't work in Ubot V5. There is a bug how V5 handles threads. That has changed compared to V4. So the following example code is for V4 only.

 

...
Link to post
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.

Loading...
×
×
  • Create New...