Exemplo n.º 1
0
        void myOnServerInitialized()
        {
            DateTime configTime;
            DateTime mainTime = DateTime.UtcNow;

            if (Config["Status"].ToString() == DisabledStr)
            {
                PrintShutdownStatus();
                return;
            }

            // Set up timer for server save and shutdown
            try
            {
                configTime = DateTime.ParseExact(Config["UTC_Time"].ToString(), TimeFormat, null);
            }
            catch (Exception e)
            {
                PrintShutdownStatus();
                return;
            }

            DateTime shutdownTime = new DateTime(mainTime.Year, mainTime.Month, mainTime.Day, configTime.Hour, configTime.Minute, configTime.Second, DateTimeKind.Utc);

            if (mainTime > shutdownTime)
            {
                shutdownTime = shutdownTime.AddDays(1);
            }
            long shutdownInterval = Convert.ToInt64((shutdownTime - mainTime).TotalSeconds);

            // schedule the server save command.
            Oxide.Core.Libraries.Timer.TimerInstance newTimer = MainTimer.Once(shutdownInterval, () => ConsoleSystem.Run.Server.Normal("server.save"));
            Timers.Add(newTimer);

            // schedule the restart command.  Restart simply shuts down the server after a 60-second countdown
            newTimer = MainTimer.Once(shutdownInterval, () => ConsoleSystem.Run.Server.Normal("restart"));
            Timers.Add(newTimer);

            PrintShutdownStatus();
        }
Exemplo n.º 2
0
 void OnServerInitialized()
 {
     MainTimer.Once(0, () => WriteConsole(string.Format("Happy Hour : Adding Happy hours.")), this);
     MainTimer.Once(0, () => CalculateTimers(), this);
 }