コード例 #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");
             }
         }
     }
 }