public void BanPlayer(ulong networkId, int minutes)
        {
            NetworkingPlayer player = Players.FirstOrDefault(p => p.NetworkId == networkId);

            if (player == null)
            {
                return;
            }

            BannedAddresses.Add(player.Ip);
        }
示例#2
0
        /// <summary>
        /// Bans the player with the given id
        /// </summary>
        /// <param name="playerID"></param>
        public void BanPlayer(int playerID)
        {
            Player player = controllers.Player.GetPlayer(playerID);

            if (player == null)
            {
                return;
            }
            string bannedAddress = player.Connection.Address.Split(':')[0];

            BannedAddresses.Add(bannedAddress);
            controllers.Player.RemovePlayer(playerID);
            Packet pOut = new Packet((int)PacketHeader.LobbyBan, "Host banned you");

            server.SendData(pOut, player.Connection);
            player.Connection.Close(1000);
            ConsoleManager.Instance.WriteLine($"Banned {bannedAddress}", MsgType.ServerInfo);
        }