Reboot Countdown

Posted by Xavaier on Fri 31 May 2002 02:10 AM — 6 posts, 27,935 views.

USA #0
I'm looking for a way to create a countdown for reboot on my mud so when I prepare to reboot I can give a 5 minute warning to everyone on the mud using Gecho.
How could this be done?
Australia Forum Administrator #1
Do you mean a warning every minute? Can you give an example?
USA #2
Well like this:

gecho This mud will be rebooted in 5 minutes
gecho this mud will be rebooted in 2 minutes
gecho this mud will be rebooted in 1 minute
gecho this mud will be rebooted in 30 seconds
gecho this mud will be rebooted in 10 seconds
gecho 5 seconds to reboot
gecho 4 seconds to reboot
gecho 3 seconds to reboot
gecho 2 seconds to reboot
gecho 1 second to reboot
reboot


Well, with the time delays ofcourse.. btw, thanks for the quick reply!!
Australia Forum Administrator #3
I would make an alias that calls a script that does a few 'doafter's, like this:


sub OnShutdown (sName, sLine, wildcards)
  world.send "gecho This mud will be rebooted in 5 minutes"
' 3 minutes later ...
  world.doafter 180, "gecho This mud will be rebooted in 2 minutes"
' 4 minutes later ...
  world.doafter 240, "gecho This mud will be rebooted in 1 minute"
' 4 mins 30 seconds later ...
  world.doafter 270, "gecho This mud will be rebooted in 30 seconds"
' 4 mins 50 seconds later ...
  world.doafter 290, "gecho This mud will be rebooted in 10 seconds"
' 4 mins 55 seconds later ...
  world.doafter 295, "gecho This mud will be rebooted in 5 seconds"
' 4 mins 56 seconds later ...
  world.doafter 296, "gecho This mud will be rebooted in 4 seconds"
' 4 mins 57 seconds later ...
  world.doafter 297, "gecho This mud will be rebooted in 3 seconds"
' 4 mins 58 seconds later ...
  world.doafter 298, "gecho This mud will be rebooted in 2 seconds"
' 4 mins 59 seconds later ...
  world.doafter 299, "gecho This mud will be rebooted in 1 second"
' reboot! ...
  world.doafter 300, "reboot mud now"
end sub
USA #4
Thanks Nick, Worked like a charm!
USA #5
if your mud has an 'uptime' like command that tells you when the next reboot will happen anyway, then maybe something like I did would be useful too:

Set a trigger to pull the days, hours, minutes and seconds till reboot from the uptime and call a Rebtimer script (Make this a perm trigger, since it could be useful to reset the time if something happens like a dropped connection). Add you uptime command to the list of things done when the mud connects, then add these routines and a timer-

Timer: 1 second interval
Calls: Distime

sub Rebtimer (trigname, output, wildcards)
  world.setvariable "Days", wildcards(1)
  world.setvariable "Hours", wildcards(2)
  world.setvariable "Minutes", wildcards(3)
  world.setvariable "Seconds", wildcards(4)
  world.status "Reboot is in " & wildcards(1) & "d " & wildcards(1) & "h " & wildcards(1) &"m."
end sub

sub Distime (Timername)
  int a
  int b
  int c
  int count
  a = Cint(world.getvariable("Days"))
  b = Cint(world.getvariable("Hours"))
  c = Cint(world.getvariable("Minutes"))
  d = Cint(world.getvariable("Seconds"))
  d = d - 1
  for count = 1 to 1
    if d < 0 then
      c = c - 1
      if c < 0 then
        b = b - 1
        if b < 0 then
          a = a - 1
          if < 0 then
            a = 0
            b = 0
            c = 0
            d = 0
            exit for 'Cheat since there is no goto and we can't simply exit sub. ;)
          end if
          b = 23
        end if
        c = 59
      end if
      d = 59
    end if
  next
  world.setvariable "Days", a
  world.setvariable "Hours", b
  world.setvariable "Minutes", c
  world.setvariable "Seconds", d
  world.status "Reboot is in " & a & "d " & b & "h " & "m."
  if a = 0 and b = 0 then
    if c < 6 then
      if c > 0 then
        world.send "gecho This mud will be rebooted in " & c & " minutes!"
      else
        if d = 30 or d <= 10
          world.send "gecho This mud will be rebooted in " & d & " seconds!"
      end if
    end if
  end if
end sub

This should produce the same results, but also gives you a running timer in the bottom left of MUCHClient telling you how long to the minute that you have left. I considered timing it to the second to be somewhat pointless anyway, so on mine I don't keep track of the seconds, but just round up a minute if there are more than 30 seconds in that field. This also makes elimination of the 'if d then' part and simplifies the gecho section, but if the mud doesn't care about you spamming it every second for the last 10, then go for it. ;) lol

------

This code does not carry a warrenty whether explicit or implied that it will work for any specfic purpose, including that for which it was designed. And by the way you really should have read these instructions 'before' opening the box... ;)