Esempio n. 1
0
 public static void SetDelay()
 {
     if (EventSchedule.infoTicker != Delay)
     {
         EventSchedule.infoTicker = Delay;
         if (Delay.Contains(",") && Delay.Contains(":"))
         {
             string[] times = Delay.Split(',');
             for (int i = 0; i < times.Length; i++)
             {
                 if (DateTime.TryParse(DateTime.Today.ToString("d") + " " + times[i] + ":00", out DateTime time))
                 {
                     if (DateTime.Now < time)
                     {
                         EventSchedule.Add("InfoTicker", time);
                         return;
                     }
                 }
             }
             for (int i = 0; i < times.Length; i++)
             {
                 if (DateTime.TryParse(DateTime.Today.AddDays(1).ToString("d") + " " + times[i] + ":00", out DateTime time))
                 {
                     if (DateTime.Now < time)
                     {
                         EventSchedule.Add("InfoTicker", time);
                         return;
                     }
                 }
             }
         }
         else if (Delay.Contains(":"))
         {
             if (DateTime.TryParse(DateTime.Today.ToString("d") + " " + Delay + ":00", out DateTime time))
             {
                 if (DateTime.Now < time)
                 {
                     EventSchedule.Add("InfoTicker", time);
                 }
                 else if (DateTime.TryParse(DateTime.Today.AddDays(1).ToString("d") + " " + Delay + ":00", out DateTime secondaryTime))
                 {
                     EventSchedule.Add("InfoTicker", secondaryTime);
                 }
             }
         }
         else
         {
             if (int.TryParse(Delay, out int delay))
             {
                 EventSchedule.Add("InfoTicker", DateTime.Now.AddMinutes(delay));
             }
             else
             {
                 Log.Out("[SERVERTOOLS] Invalid Info_Ticker Delay detected. Use a single integer, 24h time or multiple 24h time entries");
                 Log.Out("[SERVERTOOLS] Example: 120 or 03:00 or 03:00, 06:00, 09:00");
             }
         }
     }
 }
Esempio n. 2
0
 public override void Execute(List <string> _params, CommandSenderInfo _senderInfo)
 {
     try
     {
         if (_params.Count != 1)
         {
             SdtdConsole.Instance.Output(string.Format("[SERVERTOOLS] Wrong number of arguments, expected 1, found {0}", _params.Count));
             return;
         }
         if (_params[0] == "cancel")
         {
             if (!StopServer.ShuttingDown)
             {
                 SdtdConsole.Instance.Output("[SERVERTOOLS] Stopserver is not running");
             }
             else
             {
                 StopServer.ShuttingDown = false;
                 StopServer.NoEntry      = false;
                 Lottery.ShuttingDown    = false;
                 if (Shutdown.IsEnabled)
                 {
                     EventSchedule.Add("Shutdown", DateTime.Now.AddMinutes(Shutdown.Delay));
                     SdtdConsole.Instance.Output("[SERVERTOOLS] Stopserver has been cancelled and the next shutdown has been reset");
                 }
                 else
                 {
                     SdtdConsole.Instance.Output("[SERVERTOOLS] Stopserver has been cancelled");
                 }
             }
         }
         else
         {
             if (StopServer.ShuttingDown)
             {
                 SdtdConsole.Instance.Output(string.Format("[SERVERTOOLS] Server is already set to shutdown. Cancel it if you wish to set a new countdown"));
             }
             else
             {
                 if (!int.TryParse(_params[0], out StopServer.Delay))
                 {
                     SdtdConsole.Instance.Output(string.Format("[SERVERTOOLS] Invalid time specified: {0}", _params[0]));
                 }
                 else
                 {
                     StopServer.StartShutdown();
                 }
             }
         }
     }
     catch (Exception e)
     {
         Log.Out(string.Format("[SERVERTOOLS] Error in StopServerCommandConsole.Execute: {0}", e.Message));
     }
 }
Esempio n. 3
0
 public static void PrepareShutdown()
 {
     if (PersistentOperations.IsBloodmoon() && !Interrupt_Bloodmoon)
     {
         EventSchedule.Add("Shutdown", DateTime.Now.AddMinutes(10));
         if (Event.Open && !Event.OperatorWarned)
         {
             ClientInfo cInfo = PersistentOperations.GetClientInfoFromNameOrId(Event.Operator);
             if (cInfo != null)
             {
                 Event.OperatorWarned = true;
                 ChatHook.ChatMessage(cInfo, Config.Chat_Response_Color + "A scheduled shutdown is set to begin but is on hold until the bloodmoon ends" + "[-]", -1, Config.Server_Response_Name, EChatType.Whisper, null);
             }
         }
         return;
     }
     EventSchedule.Remove("Shutdown");
     StartShutdown(Countdown);
 }
 public static void PrepareShutdown()
 {
     if (Shutdown.Bloodmoon() || Event.Open)
     {
         EventSchedule.Add("Shutdown", DateTime.Now.AddMinutes(10));
         if (Event.Open && !Event.OperatorWarned)
         {
             ClientInfo _cInfo = ConsoleHelper.ParseParamIdOrName(Event.Operator);
             if (_cInfo != null)
             {
                 Event.OperatorWarned = true;
                 ChatHook.ChatMessage(_cInfo, Config.Chat_Response_Color + "A scheduled shutdown is set to begin but is on hold until the event ends" + "[-]", -1, Config.Server_Response_Name, EChatType.Whisper, null);
             }
         }
     }
     else
     {
         EventSchedule.Remove("Shutdown");
         Shutdown.Stop();
     }
 }