public static void ShutdownServer(Session session, params string[] parameters) { // inform the world that a shutdown is about to take place string shutdownInitiator = (session == null ? "Server" : session.Player.Name); string shutdownText = ""; string adminShutdownText = ""; TimeSpan timeTillShutdown = TimeSpan.FromSeconds(ServerManager.ShutdownInterval); string timeRemaining = (timeTillShutdown.TotalSeconds > 120 ? $"The server will go down in {(int)timeTillShutdown.TotalMinutes} minutes." : $"The server will go down in {timeTillShutdown.TotalSeconds} seconds."); // add admin shutdown text if (parameters?.Length > 0) { foreach (var word in parameters) { if (adminShutdownText.Length > 0) { adminShutdownText += " " + word; } else { adminShutdownText += word; } } } shutdownText += $"{shutdownInitiator} initiated a complete server shutdown @ {DateTime.UtcNow} UTC"; // output to console (log in the future) Console.WriteLine(shutdownText); Console.WriteLine(timeRemaining); if (adminShutdownText.Length > 0) { Console.WriteLine("Admin message: " + adminShutdownText); } // send a message to each player that the server will go down in x interval foreach (var player in WorldManager.GetAll()) { // send server shutdown message and time remaining till shutdown player.Network.EnqueueSend(new GameMessageSystemChat(shutdownText + "\n" + timeRemaining, ChatMessageType.Broadcast)); if (adminShutdownText.Length > 0) { player.Network.EnqueueSend(new GameMessageSystemChat($"Message from {shutdownInitiator}: {adminShutdownText}", ChatMessageType.Broadcast)); } } ServerManager.BeginShutdown(); }