Jump to content
UBot Underground

Define - Stop Script - Thread?


Recommended Posts

Hello.

 

Are Defines running in their own thread?

 

Is there a way to stop / pause a define command with the press of another button?

 

 

ui stat monitor("Status:"#testone)
ui button(1) {
    First()
    set(#testone, 1, "Global")
    set(#howmanybutton, 1, "Global")
    loop(50) {
        increment(#testone)
        wait(0.25)
    }
    increment(#howmanybutton)
}
ui button(2) {
    Second()
}
define First {
}
define Second {
    stop script
}

 

 

I know that it can be done with a variable. Something I check within the define loop. 

 

 

But I'm looking for a command which is able to stop all running activities immediately. Directly when I press the button. 

A STOP EVERYTHING command.

 

Dan

 

 

Link to post
Share on other sites

I have made you a little script so you can understand it a little better, this also works for multi-threaded scripts:

ui stat monitor("Status:", #testone)
ui button("Start") {
    Start Count()
}
ui button("Stop") {
    Stop Count()
}
comment("This Logic also works for multi-threading...")
define Start Count {
    set(#Alerted, $false, "Global")
    set(#Stop, $false, "Global")
    set(#testone, 0, "Global")
    loop(30) {
        comment("Place the \"Check Stop\" throughout your script.. ")
        Check Stop()
        increment(#testone)
        wait(0.5)
    }
}
define Stop Count {
    set(#Stop, $true, "Global")
}
define Check Stop {
    if($comparison(#Stop, "=", $true)) {
        then {
            if($comparison(#Alerted, "=", $false)) {
                then {
                    set(#Alerted, $true, "Global")
                    alert("Script Stopped!")
                }
                else {
                }
            }
            stop script
        }
        else {
        }
    }
}

Hope that helps!

 

Carl  :)

Link to post
Share on other sites

I have made you a little script so you can understand it a little better, this also works for multi-threaded scripts:

ui stat monitor("Status:", #testone)
ui button("Start") {
    Start Count()
}
ui button("Stop") {
    Stop Count()
}
comment("This Logic also works for multi-threading...")
define Start Count {
    set(#Alerted, $false, "Global")
    set(#Stop, $false, "Global")
    set(#testone, 0, "Global")
    loop(30) {
        comment("Place the \"Check Stop\" throughout your script.. ")
        Check Stop()
        increment(#testone)
        wait(0.5)
    }
}
define Stop Count {
    set(#Stop, $true, "Global")
}
define Check Stop {
    if($comparison(#Stop, "=", $true)) {
        then {
            if($comparison(#Alerted, "=", $false)) {
                then {
                    set(#Alerted, $true, "Global")
                    alert("Script Stopped!")
                }
                else {
                }
            }
            stop script
        }
        else {
        }
    }
}

Hope that helps!

 

Carl  :)

Thanks a lot for the example lazybotter. 

 

That's exactly they way I currently use im my bots. Checking a global variable within my define loops.

So the STOP command is triggered from within the running define command. 

 

If that's the only way to do it, I have to add the CheckStop command before and after all commands who take a while.

 

 

Here's an example what I mean:

ui button("Start") {

    Start Count()

}

ui button("Stop") {

    Stop Count()

}

define Start Count {

 set(#Alerted$false"Global")

    wait(10)

    alert("Test")

    Check Stop()

}

define Stop Count {

    set(#Stop$true"Global")

}

define Check Stop {

    if($comparison(#Stop"="$true)) {

        then {

            if($comparison(#Alerted"="$false)) {

                then {

                    set(#Alerted$true"Global")

                    alert("Script Stopped!")

                }

                else {

                }

            }

            stop script

        }

        else {

        }

    }

}

 

 

I would like to STOP it during the 10 second wait command. So that I don't get the TEST popup.

Of course I can add the CheckStop in front of the alert. But then it will also take 10 seconds before everything is stopped. 

Because it's stopped when the Check Stop is readched and not when I press the STOP button.

 

Hope that makes sense :-)

 

Maybe a more practical usecase for this is:

 

ui button("Start") {

    Start Download()

}

ui button("Stop") {

    Stop Download()

}

define Start Download {

    set(#Alerted$false"Global")

    Check Stop()

    download file("http://www.google.com/test.zip""test.zip")

    Check Stop()

    alert("Download Finished")

    Check Stop()

}

define Stop Download {

    set(#Stop$true"Global")

}

define Check Stop {

    if($comparison(#Stop"="$true)) {

        then {

            if($comparison(#Alerted"="$false)) {

                then {

                    set(#Alerted$true"Global")

                    alert("Script Stopped!")

                }

                else {

                }

            }

            stop script

        }

        else {

        }

    }

}

 

 

Let's assume the file has a size of 50GB.

 

How can I stop that? I think I'm looking for something like  Thread.Abort.

 

 

But at the moment I think it's not possible to do with Ubot.

 

Dan

Link to post
Share on other sites

Hey Dan why don't you make a define to do a countdown of your Delay ( 10 Seconds )

 

and check for button push every second this way stop would be instant

 

use a loop or loop while

 

 

hope this helps

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