Bryn 0 Posted March 15, 2014 Report Share Posted March 15, 2014 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? Quote Link to post Share on other sites
pash 504 Posted March 15, 2014 Report Share Posted March 15, 2014 thread { loop while($true) { wait(5) alert("Run me") } } 1 Quote Link to post Share on other sites
Bryn 0 Posted March 15, 2014 Author Report Share Posted March 15, 2014 Thanks Quote Link to post Share on other sites
Bot-Factory 602 Posted March 16, 2014 Report Share Posted March 16, 2014 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 { } }} Quote Link to post Share on other sites
Bryn 0 Posted March 16, 2014 Author Report Share Posted March 16, 2014 Thanks, good point on the button! Quote Link to post Share on other sites
Bot-Factory 602 Posted March 16, 2014 Report Share Posted March 16, 2014 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 Quote Link to post Share on other sites
luis carlos 94 Posted March 16, 2014 Report Share Posted March 16, 2014 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. ... Quote Link to post Share on other sites
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.