fCraft.World.FindPlayerExact C# (CSharp) Method

FindPlayerExact() private method

private FindPlayerExact ( [ playerName ) : Player
playerName [
return Player
        public Player FindPlayerExact( [NotNull] string playerName )
        {
            if ( playerName == null )
                throw new ArgumentNullException( "playerName" );
            Player[] tempList = Players;
            // ReSharper disable LoopCanBeConvertedToQuery
            for ( int i = 0; i < tempList.Length; i++ ) {
                if ( tempList[i] != null && tempList[i].Name.Equals( playerName, StringComparison.OrdinalIgnoreCase ) ) {
                    return tempList[i];
                }
            }
            // ReSharper restore LoopCanBeConvertedToQuery
            return null;
        }

Usage Example

Example #1
0
        void DoIPBan(Player player, IPAddress address, string reason, string playerName, bool banAll, bool unban)
        {
            Player other;

            if (unban)
            {
                if (world.bans.Remove(address))
                {
                    player.Message(address.ToString() + " has been removed from the IP ban list.");
                }
                else
                {
                    player.Message(address.ToString() + " is not currently banned.");
                }
                if (banAll)
                {
                    foreach (PlayerInfo otherInfo in world.db.FindPlayersByIP(address))
                    {
                        if (otherInfo.ProcessUnBan(player.name, reason + "~UnBanAll"))
                        {
                            player.Message(otherInfo.name + " matched the IP and was also unbanned.");
                        }
                    }
                }
            }
            else
            {
                if (world.bans.Add(new IPBanInfo(address, playerName, player.name, reason)))
                {
                    player.Message(address.ToString() + " has been added to the IP ban list.");
                }
                else
                {
                    player.Message(address.ToString() + " is already banned.");
                }
                foreach (PlayerInfo otherInfo in world.db.FindPlayersByIP(address))
                {
                    if (banAll && otherInfo.ProcessBan(player.name, reason + "~BanAll"))
                    {
                        player.Message(otherInfo.name + " matched the IP and was also banned.");
                    }
                    other = world.FindPlayerExact(otherInfo.name);
                    if (other != null)
                    {
                        other.session.Kick("Your IP was just banned by " + player.name);
                    }
                }
            }
        }
All Usage Examples Of fCraft.World::FindPlayerExact