ID:2098694
 
(See the best response by Ter13.)
Everything is in the title
mob/var/Active

mob/verb/someVerb()
src.Active=1; src<<"Active = 1"
sleep(10)//wait 1 sec. or use spawn()
src.Active=0; src<<"Active = 0"

Best response
Optionally, you can avoid the sleep() and prevent about a billion bugs down the line by using a time-tracker:

mob
var
some_delay = 0
verb
someVerb()
if(some_delay>world.time) return 0
some_delay = world.time+10
//do whatever


Anywhere you implement boolean values, you should think long and hard about whether you should be doing that.

The reason why comes down to controlling flow in a modular state machine. If you want to lengthen a boolean-based cooldown, or have a second command that can trigger the cooldown elsewhere in the code, you either need a separate boolean to track the lengthened state or alternate state, thus making checks more complex and thus error-prone, or you need to account for the possibility of an extended state by checking against some other value for consistency.

With a time-locked gate to the approach, you avoid the need to ensure boolean consistency and gain the ability to override and cancel without having to worry about interrupting the default flow of the boolean state maintenance.

Time-based values are far better for state maintenance than booleans. Booleans only make sense in an environment where booleans take less memory than float values. DM isn't one of those.

State maintenance should not be confused with capability flags though. Capability flags should use bit sequences, which are essentially just grouped up booleans. Capability flags shouldn't operate with respect to time. They may be able to change according to state, but the changes according to state should not be with respect to time, but rather time-based only incidentally.

TL;DR: If you need something to keep track of time, use time. Don't use sleep() and booleans because it's just more work in the long run for the engine and more prone to errors. Also, if you ever decide to move outside of BYOND, sleep() and spawn() very likely will not exist in the environment you move to. They are patterns that make our lives easier here in BYOND, but they are crutches that teach bad approaches and make poorly thought-through approaches possible.
Just wanted to add, that some_delay var should ideally be /tmp. Usually in such situations you don't want those things to save.
In response to Ter13
How do you exactly deal with this? Let's imagine you have this:

var/Delay = world.time +10 *10


If you had an automated system (let's imagine a board is updated after x time), wouldn't the best option be:

spawn(Delay -world.time) ...

?

I consider your option quite nice if the verb doesn't provide certain info before pressing it; but what if (for some reason) you want to make it automatically do something once that delay is over?
you want to make it automatically do something once that delay is over?

In that case, the spawn is fine.

var/time = world.time + 10
delay_time = time
spawn(10)
if(delay_time==time) //the delay hasn't been changed
//do something


There's nothing wrong with spawn() in DM. There are a very wide array of patterns for dealing with timer values depending on the use-case. It comes down to what you are trying to do as to what pattern makes the most sense.

However, the x = 1; sleep; x = 0 pattern... Frankly is one that should probably always be avoided because it's just too brittle for any actual use. IMO it's like wiring your house with aluminum wires. Yeah, it'll save you a few buck over copper, but you are gonna pay for it down the road.