[Turn off line numbering]
1: arg time, why;
2: var increments, line, name, mins, secs;
3:
4: if (!$sys.is_admin(sender()) || definer() != this())
5: throw(~perm, "Sender is not an admin.");
6: increments = [600, 300, 180, 60];
7: secs = time * 60;
8: while (increments && secs < increments[1])
9: increments = increments.delete(1);
10: if (increments && secs > increments[1])
11: increments = [secs] + increments;
12: name = sender().namef('xref);
13: .log("*** SHUTDOWN called by " + name + " ***");
14: if (why) {
15: why = "*** REASON: " + why + " ***";
16: .log(why);
17: }
18: while (1) {
19: if (!increments) {
20: $channel_ui._broadcast('All, "*** SYSTEM SHUTDOWN ***");
21: if (why)
22: $channel_ui._broadcast('All, why);
23: break;
24: }
25: line = "*** SYSTEM SHUTDOWN IN ";
26: mins = increments[1] / 60;
27: line = line + tostr(mins) + " MINUTE" + (mins == 1 ? "" : "S");
28: line = line + " CALLED BY " + name + " ***";
29: $channel_ui._broadcast('All, line);
30: if (why)
31: $channel_ui._broadcast('All, why);
32: if (increments.length() > 1)
33: $scheduler.sleep(increments[1] - increments[2]);
34: else
35: $scheduler.sleep(increments[1]);
36: increments = increments.delete(1);
37: }
38: pause();
39: pause();
40: return .shutdown();
["// Created 26-Mar-1995 as a part of ColdCore, see: @help Credit"]