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");
             }
         }
     }
 }
Beispiel #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));
     }
 }
Beispiel #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();
     }
 }
Beispiel #5
0
 private static void Exec()
 {
     PersistentOperations.PlayerCheck();
     if (Jail.IsEnabled)
     {
         Jail.StatusCheck();
     }
     if (DiscordBot.IsEnabled && DiscordBot.Queue.Count > 0)
     {
         DiscordBot.WebHook();
     }
     if (_twoSecondTick >= 2)
     {
         _twoSecondTick = 0;
         if (WorldRadius.IsEnabled)
         {
             WorldRadius.Exec();
         }
         if (PlayerChecks.GodEnabled || PlayerChecks.FlyEnabled || PlayerChecks.SpectatorEnabled || PlayerChecks.WaterEnabled)
         {
             PlayerChecks.Exec();
         }
     }
     if (_fiveSecondTick >= 5)
     {
         _fiveSecondTick = 0;
         if (Zones.IsEnabled)
         {
             Zones.HostileCheck();
         }
         if (PlayerStats.IsEnabled)
         {
             PlayerStats.Exec();
         }
     }
     if (_tenSecondTick >= 10)
     {
         _tenSecondTick = 0;
         if (EntityCleanup.IsEnabled)
         {
             EntityCleanup.EntityCheck();
         }
         EventSchedule.Exec();
     }
     if (_twentySecondTick >= 20)
     {
         _twentySecondTick = 0;
         if (Track.IsEnabled)
         {
             Track.Exec();
         }
     }
     if (_oneMinTick >= 60)
     {
         _oneMinTick = 0;
         if (Jail.IsEnabled && Jail.Jailed.Count > 0)
         {
             Jail.Clear();
         }
         if (Mute.IsEnabled && Mute.Mutes.Count > 0)
         {
             Mute.Clear();
         }
         if (BloodmoonWarrior.IsEnabled)
         {
             BloodmoonWarrior.Exec();
         }
     }
     if (_fiveMinTick >= 300)
     {
         _fiveMinTick = 0;
         StateManager.Save();
         if (InvalidItems.Check_Storage)
         {
             InvalidItems.CheckStorage();
         }
     }
     if (WeatherVote.IsEnabled && WeatherVote.VoteOpen)
     {
         _weatherVote++;
         if (_weatherVote >= 60)
         {
             _weatherVote         = 0;
             WeatherVote.VoteOpen = false;
             WeatherVote.ProcessWeatherVote();
         }
     }
     if (RestartVote.IsEnabled && RestartVote.VoteOpen)
     {
         _restartVote++;
         if (_restartVote >= 60)
         {
             _restartVote         = 0;
             RestartVote.VoteOpen = false;
             RestartVote.ProcessRestartVote();
         }
     }
     if (MuteVote.IsEnabled && MuteVote.VoteOpen)
     {
         _muteVote++;
         if (_muteVote >= 60)
         {
             _muteVote         = 0;
             MuteVote.VoteOpen = false;
             MuteVote.ProcessMuteVote();
         }
     }
     if (KickVote.IsEnabled && KickVote.VoteOpen)
     {
         _kickVote++;
         if (_kickVote >= 60)
         {
             _kickVote         = 0;
             KickVote.VoteOpen = false;
             KickVote.ProcessKickVote();
         }
     }
     if (Lottery.IsEnabled && Lottery.OpenLotto)
     {
         _lottery++;
         if (_lottery == 3300)
         {
             Lottery.Alert();
         }
         if (_lottery >= 3600)
         {
             _lottery = 0;
             Lottery.StartLotto();
         }
     }
     else
     {
         _lottery = 0;
     }
     if (Hordes.IsEnabled)
     {
         _horde++;
         if (_horde >= 1200)
         {
             _horde = 0;
             Hordes.Exec();
         }
     }
     else
     {
         _horde = 0;
     }
     if (StopServer.ShuttingDown)
     {
         _stopServerSeconds++;
         if (_stopServerSeconds >= 60)
         {
             _stopServerSeconds = 0;
             StopServerMinutes--;
             if (StopServerMinutes > 1)
             {
                 StopServer.TimeRemaining(StopServerMinutes);
             }
             else if (StopServerMinutes == 1)
             {
                 StopServer.OneMinuteRemains();
             }
             else if (StopServerMinutes == 0)
             {
                 StopServer.ShuttingDown = false;
                 StopServer.Stop();
             }
         }
         if (_stopServerSeconds == 30 && StopServerMinutes == 1)
         {
             StopServer.Kick30();
         }
     }
     else
     {
         _stopServerSeconds = 0;
     }
     if (Event.Invited)
     {
         _eventInvitation++;
         if (_eventInvitation >= 900)
         {
             _eventInvitation = 0;
             Event.Invited    = false;
             Event.CheckOpen();
         }
     }
     if (Event.Open)
     {
         _eventOpen++;
         if (_eventOpen == _eventTime / 2)
         {
             Event.HalfTime();
         }
         if (_eventOpen == _eventTime - 300)
         {
             Event.FiveMin();
         }
         if (_eventOpen >= _eventTime)
         {
             _eventOpen = 0;
             Event.EndEvent();
         }
     }
     else
     {
         _eventOpen = 0;
     }
     if (RestartVote.Cycle)
     {
         _restartVoteCycle++;
         if (_restartVoteCycle >= 1800)
         {
             RestartVote.Cycle = false;
         }
     }
 }
Beispiel #6
0
 private static void Exec()
 {
     if (Zones.IsEnabled || Lobby.IsEnabled || Market.IsEnabled)
     {
         PersistentOperations.CheckZone();
     }
     if (Jail.IsEnabled)
     {
         Jail.StatusCheck();
     }
     if (DiscordBot.IsEnabled && DiscordBot.Queue.Count > 0)
     {
         DiscordBot.WebHook();
     }
     if (twoSecondTick >= 2)
     {
         twoSecondTick = 0;
         if (PlayerChecks.GodEnabled || PlayerChecks.SpectatorEnabled || FlyingDetector.IsEnabled || SpeedDetector.IsEnabled)
         {
             PlayerChecks.TwoSecondExec();
         }
         if (WorldRadius.IsEnabled)
         {
             WorldRadius.Exec();
         }
     }
     if (fiveSecondTick >= 5)
     {
         fiveSecondTick = 0;
         if (Zones.IsEnabled)
         {
             Zones.HostileCheck();
         }
         if (PlayerStats.IsEnabled)
         {
             PlayerStats.Exec();
         }
         if (Fps.IsEnabled)
         {
             Fps.LowFPS();
         }
     }
     if (tenSecondTick >= 10)
     {
         tenSecondTick = 0;
         if (EntityCleanup.IsEnabled)
         {
             EntityCleanup.EntityCheck();
         }
     }
     if (twentySecondTick >= 20)
     {
         twentySecondTick = 0;
         if (Track.IsEnabled)
         {
             Track.Exec();
         }
         EventSchedule.Exec();
     }
     if (oneMinTick >= 60)
     {
         oneMinTick = 0;
         if (Jail.IsEnabled && Jail.Jailed.Count > 0)
         {
             Jail.Clear();
         }
         if (Mute.IsEnabled && Mute.Mutes.Count > 0)
         {
             Mute.Clear();
         }
         if (BloodmoonWarrior.IsEnabled)
         {
             BloodmoonWarrior.Exec();
         }
     }
     if (fiveMinTick >= 300)
     {
         fiveMinTick = 0;
         StateManager.Save();
         if (InvalidItems.Check_Storage)
         {
             InvalidItems.CheckStorage();
         }
     }
     if (PersistentOperations.NewPlayerQue.Count > 0)
     {
         newPlayer++;
         if (newPlayer >= 5)
         {
             newPlayer = 0;
             ClientInfo cInfo = PersistentOperations.NewPlayerQue[0];
             PersistentOperations.NewPlayerQue.RemoveAt(0);
             API.NewPlayerExec(cInfo);
         }
     }
     if (RestartVote.IsEnabled && RestartVote.VoteOpen)
     {
         restartVote++;
         if (restartVote >= 60)
         {
             restartVote          = 0;
             RestartVote.VoteOpen = false;
             RestartVote.ProcessRestartVote();
         }
     }
     if (MuteVote.IsEnabled && MuteVote.VoteOpen)
     {
         muteVote++;
         if (muteVote >= 60)
         {
             muteVote          = 0;
             MuteVote.VoteOpen = false;
             MuteVote.ProcessMuteVote();
         }
     }
     if (KickVote.IsEnabled && KickVote.VoteOpen)
     {
         kickVote++;
         if (kickVote >= 60)
         {
             kickVote          = 0;
             KickVote.VoteOpen = false;
             KickVote.ProcessKickVote();
         }
     }
     if (Lottery.IsEnabled && Lottery.OpenLotto)
     {
         lottery++;
         if (lottery == Lottery.Time * 60 - 60)
         {
             Lottery.Alert();
         }
         if (lottery >= Lottery.Time * 60)
         {
             lottery           = 0;
             Lottery.OpenLotto = false;
             Lottery.StartLotto();
         }
     }
     else
     {
         lottery = 0;
     }
     if (Hordes.IsEnabled)
     {
         horde++;
         if (horde >= 1200)
         {
             horde = 0;
             Hordes.Exec();
         }
     }
     else
     {
         horde = 0;
     }
     if (Shutdown.ShuttingDown)
     {
         stopServerSeconds++;
         if (stopServerSeconds >= 60)
         {
             stopServerSeconds = 0;
             StopServerMinutes--;
             if (StopServerMinutes > 1)
             {
                 Shutdown.TimeRemaining(StopServerMinutes);
             }
             else if (StopServerMinutes == 1)
             {
                 Shutdown.OneMinute();
             }
             else if (StopServerMinutes == 0)
             {
                 Shutdown.ShuttingDown = false;
                 Shutdown.Close();
             }
         }
         if (StopServerMinutes == 1)
         {
             if (Shutdown.UI_Lock && stopServerSeconds == 15)
             {
                 Shutdown.Lock();
             }
             else if (stopServerSeconds == 30)
             {
                 Shutdown.Kick();
             }
         }
     }
     else
     {
         stopServerSeconds = 0;
     }
     if (Event.Invited)
     {
         eventInvitation++;
         if (eventInvitation >= 900)
         {
             eventInvitation = 0;
             Event.Invited   = false;
             Event.CheckOpen();
         }
     }
     if (Event.Open)
     {
         eventOpen++;
         if (eventOpen == eventTime / 2)
         {
             Event.HalfTime();
         }
         if (eventOpen == eventTime - 300)
         {
             Event.FiveMin();
         }
         if (eventOpen >= eventTime)
         {
             eventOpen = 0;
             Event.EndEvent();
         }
     }
     else
     {
         eventOpen = 0;
     }
 }