ID:269113
 
Hello ive tired a few ways of trying to halt my Reboot but no luck maybe you guys can help me out


            AdminReboot()
set name = "Admin: Reboot"
set category = "Admin"
switch(alert("Are you sure you wish to Reboot?",A,"Yes","No"))
if("Yes")
var/time = input("How many seconds till reboot?",A) as num
AdminSystem("World will reboot in [time] seconds!")
time = time * 10
sleep(time)

world.Reboot()


Say i put reboot in 10 secondes but then i thought never mind so you put in 0 to halt it.

can anyone help me out

sleep(time/2)
src.stillreboot()
sleep(time/2)
if(noreboot)//if you havent changed your mind continue with the reboot
world.Reboot()


for the stillreboot() proc make it check if they changed they mind. Keep in mind though it has to be done in at least half the time it was initiated for.

~>Jiskuha
try:

add a global variable
var
rebooting = 0


then modify your reboot verb:
time = input() as num|null
if(time!=null||time>0)
global.rebooting = 1
sleep(time*10)
if(global.rebooting)
//reboot code here
else
global.rebooting = 0


This will add a cancel button to the input box, and make you able to override the reboot.

then, make another verb to cancel an already existing reboot.

verb
cancel_reboot()
global.rebooting = 0


[edit] after re-reading your post, I figured you might have been asking for something else.
Logging out works, but you can also use a variable to keep the reboot time:

var
reboot_time=-1
mob
admin
verb
AdminRebootCancel()
set name = "Admin: Reboot Abort"
set category = "Admin"
reboot_time=-1
AdminSystem("World reboot aborted!")
AdminReboot()
set name = "Admin: Reboot"
set category = "Admin"
switch(alert("Are you sure you wish to Reboot?",A,"Yes","No"))
if("Yes")
reboot_time = input("How many seconds till reboot?",A) as num
AdminSystem("World will reboot in [time] seconds!")
while(reboot_time)
sleep(10)
reboot_time--
if(reboot_time>=0)world.Reboot()
In response to Nick231
Thanks Everyone