ID:269365
 
Hwo would I create a timer? I know I've asked something similar to this question before, but I couldn't find the topic..
var
const
second=10
minute=600
hour=36000
proc
unit2text(unit,plural=0,capital=0)
switch(unit)
if(second)
return "[capital?"S":"s"]econd[plural?"s":null]"
if(minute)
return "[capital?"M":"m"]inute[plural?"s":null]"
if(hour)
return "[capital?"H":"h"]our[plural?"s":null]"
timer(unit=second,time=second,timedown=1)
time/=10
while(time>0)
sleep(unit)
time-=timedown
return 1
mob
verb
reboot()
var/list/units=list("Seconds"=second,"Minutes"=minute,"Hours"=hour)
var/unit=input("Which measure of units would like to use in this?")in units
unit=units[unit]
var/time=input("How many [unit2text(unit,1)] would you like to use?")as num
if(!isnum(time)||!time)return
for(var/i=1 to time)
while(!timer(unit,unit))
if(time-1>0)world<<"World rebooting in [round((time+1)-i)] [i!=time-1?unit2text(unit,1):unit2text(unit)]!"
world.Reboot()


I made this awhile ago, so it may not work. :p
But, it worked when I tried it, so meh.
Mess with world.timeofday, or world.realtime.
In response to Hell Ramen
sleep(100) //Timer set for 10 seconds until the next action is done.


Remember, it's in ticks, or 1/10th of a second, so always think like 10 times X, where X = how many seconds you want to have it wait.

EDIT: If you wanted to do a reboot...

mob/verb/reboot()
if(alert("Are you sure?","Reboot","Yes","No") == "Yes")
world<<"Server rebooting in 10 seconds!"
sleep(100)
world.Reboot()


//Or, if you want it do be divided...

mob/verb/reboot()
if(alert("Are you sure?","Reboot","Yes","No") == "Yes")
world<<"Server rebooting in 10 seconds!"
sleep(50)
world<<"Server rebooting in 5 seconds!"
sleep(50)
world.Reboot()
In response to Terranwolf
The second reboot code is messed up. It's gonna say World rebooting in 5 seconds and reboot.
In response to CIB
Ah, thanks for catching that. I didn't run it in DM.
In response to Terranwolf
Oh c'mon, mine you can set to any time. :p