Pizza Pro 11 Posted August 27, 2013 Report Share Posted August 27, 2013 Hi guys. I'm currently moving over to using UI Buttons to run my bot. I was wondering if there's any way to stop my bot once it has started running with a UI button? I tried attaching a stop script to a Stop UI Button, but it doesn't seem to work... Quote Link to post Share on other sites
danoctav 7 Posted August 27, 2013 Report Share Posted August 27, 2013 2 simple examples: Example nr. 1: ui stat monitor("Generate random numbers", #generaterandomnumbers) comment("---generating random numbers until press <Stop Script> button ------") ui button("Run") { set(#stop, $false, "Global") set(#i, 0, "Global") loop while($comparison(#stop, "!=", $true)) { set(#generaterandomnumbers, $rand(0, 100000), "Global") increment(#i) } } ui button("Stop Script") { set(#stop, $true, "Global") } Example nr. 2: ui stat monitor("Generate random numbers", #generaterandomnumbers) ui stat monitor("Generate random numbers", #generaterandomletters) comment("---generating random numbers and words until press <Stop Script> button ------") ui button("Run") { set(#stop, $false, "Global") set(#i, 0, "Global") loop($rand(25, 50)) { if($comparison(#stop, "=", $true)) { then { stop script } else { } } set(#generaterandomnumbers, $rand(0, 100000), "Global") set(#generaterandomletters, $random text($rand(3, 5)), "Global") increment(#i) wait(1) } } ui button("Stop Script") { set(#stop, $true, "Global") } 1 Quote Link to post Share on other sites
darryl561 177 Posted August 27, 2013 Report Share Posted August 27, 2013 Take a look at this thread: http://www.ubotstudio.com/forum/index.php?/topic/12766-how-does-pause-script-and-stop-script-work/ In particular post #14 by magoo. 1 Quote Link to post Share on other sites
Pizza Pro 11 Posted August 27, 2013 Author Report Share Posted August 27, 2013 Thanks a lot guys! I will look into those and try them out. Quote Link to post Share on other sites
Pizza Pro 11 Posted August 30, 2013 Author Report Share Posted August 30, 2013 I've been going through this, and it seems that the only way at the moment is to set a variable between true and false, within a loop statement, with the stop button changing the variable to false to stop the script.... Am I correct? This seems to work for shorter scripts. But what if I wanted my UI button to run a very long process? It would only be able to stop once the program loops at least once I guess... I can't stop it half-way, like the UBot Stop Button does... Unless maybe I put statements throughout the code, which is a bit troublesome. Are there any other ways around this? Else I guess I'd better go back to using the Run and Stop buttons instead of the UI Button... Quote Link to post Share on other sites
Gogetta 263 Posted September 7, 2013 Report Share Posted September 7, 2013 I've been going through this, and it seems that the only way at the moment is to set a variable between true and false, within a loop statement, with the stop button changing the variable to false to stop the script.... Am I correct? This seems to work for shorter scripts. But what if I wanted my UI button to run a very long process? It would only be able to stop once the program loops at least once I guess... I can't stop it half-way, like the UBot Stop Button does... Unless maybe I put statements throughout the code, which is a bit troublesome. Are there any other ways around this? Else I guess I'd better go back to using the Run and Stop buttons instead of the UI Button... I wanted to also reply to this thread. Sorry guys, but these examples posted here are not right. By using an if statement from inside of a loop will only cause your bot to stop once it loops back around. Not really the ideal way to stop a bot using a UI button. What I think that you are missing is you need to run a loop while inside of a thread at the top of your start button. That way whenever the variable changes from true to false it will stop your script the moment the button is clicked. Check my post here for the example. http://www.ubotstudio.com/forum/index.php?/topic/14767-an-easier-way-to-stop-script-when-using-the-ui-button/&do=findComment&comment=83501 1 Quote Link to post Share on other sites
Pizza Pro 11 Posted September 9, 2013 Author Report Share Posted September 9, 2013 I wanted to also reply to this thread. Sorry guys, but these examples posted here are not right. By using an if statement from inside of a loop will only cause your bot to stop once it loops back around. Not really the ideal way to stop a bot using a UI button. What I think that you are missing is you need to run a loop while inside of a thread at the top of your start button. That way whenever the variable changes from true to false it will stop your script the moment the button is clicked. Check my post here for the example. http://www.ubotstudio.com/forum/index.php?/topic/14767-an-easier-way-to-stop-script-when-using-the-ui-button/&do=findComment&comment=83501 Thanks a lot Gogetta. I will check it out now. I was wondering why it was so difficult to do. I'll look at your example. 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.