private static bool HandleCommandKick(string input) { if (input == ":all") { gameServer.KickAllPlayers(); Log.Write(LogType.Info, "All players were kicked from the server!"); } else if (int.TryParse(input, out int playerIndex)) { if (gameServer.KickPlayer((byte)playerIndex)) { Log.Write(LogType.Info, "Player was kicked from the server!"); } else { Log.Write(LogType.Error, "Player was not found!"); } } else { GameServer.PlayerClient player = gameServer.FindPlayerByUserName(input); if (player != null && gameServer.KickPlayer(player.Index)) { Log.Write(LogType.Info, "Player was kicked from the server!"); } else { Log.Write(LogType.Error, "Player was not found!"); } } return(true); }
private static bool HandleCommandKick(string input) { int playerIndex; if (input == ":all") { gameServer.KickAllPlayers(); Log.Write(LogType.Info, "All players were kicked from the server!"); } else if (int.TryParse(input, out playerIndex)) { if (gameServer.KickPlayer((byte)playerIndex)) { Log.Write(LogType.Info, "Player was kicked from the server!"); } else { Log.Write(LogType.Error, "Player was not found!"); } } else { Log.Write(LogType.Error, "You have to specify player index! (or :all to kick all players)"); } return(true); }