Пример #1
0
        void cmdChatBanTP(BasePlayer player, string command, string[] args)
        {
            if (!PermissionService.HasPermission(player.userID, BAN_PERM))
            {
                SendReply(player, "Недостаточно прав!");
                return;
            }
            var bannedPlayers =
                BasePlayer.sleepingPlayerList.Where(p => ServerUsers.Get(p.userID)?.@group == ServerUsers.UserGroup.Banned ||
                                                    bans.ContainsKey(p.userID)).ToList();

            if (args.Length == 0)
            {
                string msgPlayers = "";
                for (var i = 0; i < bannedPlayers.Count; i++)
                {
                    var p = bannedPlayers[i];
                    msgPlayers += $"[<color=orange>{i}</color> ({p.userID}/{p.displayName})] ";
                }
                SendReply(player, msgPlayers);
                return;
            }
            int index;

            if (!int.TryParse(args[0], out index))
            {
                SendReply(player, "НЕВЕРНО: пример /bantp 0");
                return;
            }
            core.Teleport(player, bannedPlayers[index]);
        }
Пример #2
0
        public virtual ValidationResult Validate()
        {
            int orGenerateAppToken = SingletonComponent <ServerMgr> .Instance.persistance.GetOrGenerateAppToken(Request.playerId);

            if (Request.playerId == 0L || Request.playerToken != orGenerateAppToken)
            {
                return(ValidationResult.NotFound);
            }
            if ((ServerUsers.Get(Request.playerId)?.group ?? ServerUsers.UserGroup.None) == ServerUsers.UserGroup.Banned)
            {
                return(ValidationResult.Banned);
            }
            TokenBucket tokenBucket = _playerBuckets?.Get(Request.playerId);

            if (tokenBucket == null || !tokenBucket.TryTake(TokenCost))
            {
                if (tokenBucket == null || !tokenBucket.IsNaughty)
                {
                    return(ValidationResult.RateLimit);
                }
                return(ValidationResult.Rejected);
            }
            UserId = Request.playerId;
            Player = BasePlayer.FindByID(UserId) ?? BasePlayer.FindSleeping(UserId);
            Client.Subscribe(new PlayerTarget(UserId));
            return(ValidationResult.Success);
        }
Пример #3
0
        private void Ban(ConsoleSystem.Arg args)
        {
            BasePlayer player = args.GetPlayer(0);

            if (player == null || player.net == null)
            {
                return;
            }

            string name   = args.GetString(1, "unnamed");
            string reason = args.GetString(2, "no reason");

            var user = ServerUsers.Get(player.userID);

            if (user != null)
            {
                if (UsernameValid(player.userID, name))
                {
                    name = user.username;
                }
            }
            user.group = ServerUsers.UserGroup.Banned;

            if (Settings.Instance.PushedAllLocalBansToDatabase)
            {
                PushBansToServer();
            }
        }
Пример #4
0
        private void BanID(ConsoleSystem.Arg args)
        {
            ulong  steamID = args.GetUInt64(0, 0uL);
            string name    = args.GetString(1, "unnamed");
            string reason  = args.GetString(2, "no reason");

            if (steamID == 0)
            {
                return;
            }

            var user = ServerUsers.Get(steamID);

            if (user != null)
            {
                if (UsernameValid(steamID, name))
                {
                    name = user.username;
                }
            }
            user.group = ServerUsers.UserGroup.Banned;

            if (Settings.Instance.PushedAllLocalBansToDatabase)
            {
                PushBansToServer();
            }
        }
Пример #5
0
        //Not really a hook but sorta as we are copy paste overwriting it
        void OverwriteBanCommand(ConsoleSystem.Arg arg)
        {
            BasePlayer player = ArgEx.GetPlayer(arg, 0);

            if (!(bool)player || player.net == null || player.net.connection == null)
            {
                arg.ReplyWith("Player not found");
            }
            else
            {
                ServerUsers.User user = ServerUsers.Get(player.userID);
                if (user != null && user.group == ServerUsers.UserGroup.Banned)
                {
                    arg.ReplyWith("User " + player.userID + " is already banned");
                }
                else
                {
                    string @string = arg.GetString(1, "No Reason Given");
                    ServerUsers.Set(player.userID, ServerUsers.UserGroup.Banned, player.displayName, @string);
                    string text = string.Empty;
                    if (player.IsConnected && player.net.connection.ownerid != player.net.connection.userid)
                    {
                        text = text + " and also banned ownerid " + player.net.connection.ownerid;
                        ServerUsers.Set(player.net.connection.ownerid, ServerUsers.UserGroup.Banned, player.displayName, arg.GetString(1, "Family share owner of " + player.net.connection.userid));
                    }
                    //We don't actually have to save, because we save on user group changed
                    //OnServerSaveUsers();
                    //ServerUsers.Save();
                    arg.ReplyWith("Kickbanned User: "******" - " + player.displayName + text);
                    PrintToChat("Kickbanning " + player.displayName + " (" + @string + ")", "SERVER", "#eee", 0uL);
                    Network.Net.sv.Kick(player.net.connection, "Banned: " + @string);
                }
            }
        }
Пример #6
0
        public static void ban(ConsoleSystem.Arg arg)
        {
            BasePlayer player = arg.GetPlayer(0);

            if (!Object.op_Implicit((Object)player) || player.net == null || player.net.get_connection() == null)
            {
                arg.ReplyWith("Player not found");
            }
            else
            {
                ServerUsers.User user = ServerUsers.Get(player.userID);
                if (user != null && user.group == ServerUsers.UserGroup.Banned)
                {
                    arg.ReplyWith("User " + (object)player.userID + " is already banned");
                }
                else
                {
                    string notes = arg.GetString(1, "No Reason Given");
                    ServerUsers.Set(player.userID, ServerUsers.UserGroup.Banned, player.displayName, notes);
                    string str = "";
                    if (player.IsConnected && player.net.get_connection().ownerid != player.net.get_connection().userid)
                    {
                        str = str + " and also banned ownerid " + (object)(ulong)player.net.get_connection().ownerid;
                        ServerUsers.Set((ulong)player.net.get_connection().ownerid, ServerUsers.UserGroup.Banned, player.displayName, arg.GetString(1, "Family share owner of " + (object)(ulong)player.net.get_connection().userid));
                    }
                    ServerUsers.Save();
                    arg.ReplyWith("Kickbanned User: "******" - " + player.displayName + str);
                    Chat.Broadcast("Kickbanning " + player.displayName + " (" + notes + ")", "SERVER", "#eee", 0UL);
                    ((Server)Net.sv).Kick(player.net.get_connection(), "Banned: " + notes);
                }
            }
        }
Пример #7
0
        public static void ban(Arg arg)
        {
            BasePlayer player = ArgEx.GetPlayer(arg, 0);

            if (!player || player.net == null || player.net.connection == null)
            {
                arg.ReplyWith("Player not found");
                return;
            }
            ServerUsers.User user = ServerUsers.Get(player.userID);
            if (user != null && user.group == ServerUsers.UserGroup.Banned)
            {
                arg.ReplyWith($"User {player.userID} is already banned");
                return;
            }
            string @string = arg.GetString(1, "No Reason Given");
            long   expiry;
            string durationSuffix;

            if (TryGetBanExpiry(arg, 2, out expiry, out durationSuffix))
            {
                ServerUsers.Set(player.userID, ServerUsers.UserGroup.Banned, player.displayName, @string, expiry);
                string text = "";
                if (player.IsConnected && player.net.connection.ownerid != 0L && player.net.connection.ownerid != player.net.connection.userid)
                {
                    text += $" and also banned ownerid {player.net.connection.ownerid}";
                    ServerUsers.Set(player.net.connection.ownerid, ServerUsers.UserGroup.Banned, player.displayName, arg.GetString(1, $"Family share owner of {player.net.connection.userid}"), -1L);
                }
                ServerUsers.Save();
                arg.ReplyWith($"Kickbanned User{durationSuffix}: {player.userID} - {player.displayName}{text}");
                Chat.Broadcast("Kickbanning " + player.displayName + durationSuffix + " (" + @string + ")", "SERVER", "#eee", 0uL);
                Network.Net.sv.Kick(player.net.connection, "Banned" + durationSuffix + ": " + @string);
            }
        }
Пример #8
0
        public static void ban(ConsoleSystem.Arg arg)
        {
            BasePlayer player = arg.GetPlayer(0);

            if (!player || player.net == null || player.net.connection == null)
            {
                arg.ReplyWith("Player not found");
                return;
            }
            ServerUsers.User user = ServerUsers.Get(player.userID);
            if (user != null && user.@group == ServerUsers.UserGroup.Banned)
            {
                arg.ReplyWith(string.Concat("User ", player.userID, " is already banned"));
                return;
            }
            string str = arg.GetString(1, "No Reason Given");

            ServerUsers.Set(player.userID, ServerUsers.UserGroup.Banned, player.displayName, str);
            string str1 = "";

            if (player.IsConnected && player.net.connection.ownerid != player.net.connection.userid)
            {
                str1 = string.Concat(str1, " and also banned ownerid ", player.net.connection.ownerid);
                ServerUsers.Set(player.net.connection.ownerid, ServerUsers.UserGroup.Banned, player.displayName, arg.GetString(1, string.Concat("Family share owner of ", player.net.connection.userid)));
            }
            ServerUsers.Save();
            arg.ReplyWith(string.Concat(new object[] { "Kickbanned User: "******" - ", player.displayName, str1 }));
            Chat.Broadcast(string.Concat(new string[] { "Kickbanning ", player.displayName, " (", str, ")" }), "SERVER", "#eee", (ulong)0);
            Network.Net.sv.Kick(player.net.connection, string.Concat("Banned: ", str));
        }
Пример #9
0
 private void ProcessUnban(IPlayer player, JObject clan)
 {
     foreach (var member in clan["members"])
     {
         var target = covalence.Players.FindPlayerById(Convert.ToString(member));
         if (type == 1)
         {
             EnhancedBanSystem.Call("TryUnBan", player.Name, new string[1] {
                 target.Id
             });
         }
         else
         {
             var exists = ServerUsers.Get(ulong.Parse(target.Id));
             if (exists != null && exists.group != ServerUsers.UserGroup.Banned)
             {
                 SendMessage(player, GetLang("AlreadyUnbanned", player.Id, target.Name));
                 return;
             }
             ServerUsers.Remove(ulong.Parse(target.Id));
             ServerUsers.Save();
             server.Broadcast(GetLang("PlayerUnbanned", null, target.Name));
         }
     }
     if (AnnounceToServer)
     {
         server.Broadcast(GetLang("UnbanMessage", null, clan["tag"]));
     }
 }
Пример #10
0
 public static bool Is(ulong uid, ServerUsers.UserGroup group)
 {
     ServerUsers.User user = ServerUsers.Get(uid);
     if (user == null)
     {
         return(false);
     }
     return(user.group == group);
 }
Пример #11
0
 public void OnNewConnection(Connection connection)
 {
     connection.connected = false;
     if (connection.token == null || connection.token.Length < 32)
     {
         Reject(connection, "Invalid Token");
         return;
     }
     if (connection.userid == 0L)
     {
         Reject(connection, "Invalid SteamID");
         return;
     }
     if (connection.protocol != 2306)
     {
         if (!DeveloperList.Contains(connection.userid))
         {
             Reject(connection, "Incompatible Version");
             return;
         }
         DebugEx.Log("Not kicking " + connection.userid + " for incompatible protocol (is a developer)");
     }
     if (ServerUsers.Is(connection.userid, ServerUsers.UserGroup.Banned))
     {
         ServerUsers.User user  = ServerUsers.Get(connection.userid);
         string           text  = user?.notes ?? "no reason given";
         string           text2 = ((user != null && user.expiry > 0) ? (" for " + (user.expiry - Epoch.Current).FormatSecondsLong()) : "");
         Reject(connection, "You are banned from this server" + text2 + " (" + text + ")");
         return;
     }
     if (ServerUsers.Is(connection.userid, ServerUsers.UserGroup.Moderator))
     {
         DebugEx.Log(connection.ToString() + " has auth level 1");
         connection.authLevel = 1u;
     }
     if (ServerUsers.Is(connection.userid, ServerUsers.UserGroup.Owner))
     {
         DebugEx.Log(connection.ToString() + " has auth level 2");
         connection.authLevel = 2u;
     }
     if (DeveloperList.Contains(connection.userid))
     {
         DebugEx.Log(connection.ToString() + " is a developer");
         connection.authLevel = 3u;
     }
     if (Interface.CallHook("IOnUserApprove", connection) == null)
     {
         m_AuthConnection.Add(connection);
         StartCoroutine(AuthorisationRoutine(connection));
     }
 }
Пример #12
0
    private bool CanJumpQueue(Connection connection)
    {
        object obj = Interface.CallHook("CanBypassQueue", (object)connection);

        if (obj is bool)
        {
            return((bool)obj);
        }
        if (DeveloperList.Contains((ulong)connection.userid))
        {
            return(true);
        }
        ServerUsers.User user = ServerUsers.Get((ulong)connection.userid);
        return(user != null && user.group == ServerUsers.UserGroup.Moderator || user != null && user.group == ServerUsers.UserGroup.Owner);
    }
Пример #13
0
        public static void removeowner(Arg arg)
        {
            ulong uInt = arg.GetUInt64(0, 0uL);

            if (uInt < 70000000000000000L)
            {
                arg.ReplyWith("This doesn't appear to be a 64bit steamid: " + uInt);
                return;
            }
            ServerUsers.User user = ServerUsers.Get(uInt);
            if (user == null || user.group != ServerUsers.UserGroup.Owner)
            {
                arg.ReplyWith("User " + uInt + " isn't an owner");
                return;
            }
            ServerUsers.Remove(uInt);
            arg.ReplyWith("Removed Owner: " + uInt);
        }
Пример #14
0
        public static void unban(Arg arg)
        {
            ulong uInt = arg.GetUInt64(0, 0uL);

            if (uInt < 70000000000000000L)
            {
                arg.ReplyWith($"This doesn't appear to be a 64bit steamid: {uInt}");
                return;
            }
            ServerUsers.User user = ServerUsers.Get(uInt);
            if (user == null || user.group != ServerUsers.UserGroup.Banned)
            {
                arg.ReplyWith($"User {uInt} isn't banned");
                return;
            }
            ServerUsers.Remove(uInt);
            arg.ReplyWith("Unbanned User: " + uInt);
        }
Пример #15
0
        public static void unban(ConsoleSystem.Arg arg)
        {
            ulong num = arg.GetUInt64(0, (ulong)0);

            if (num < 70000000000000000L)
            {
                arg.ReplyWith(string.Concat("This doesn't appear to be a 64bit steamid: ", num));
                return;
            }
            ServerUsers.User user = ServerUsers.Get(num);
            if (user == null || user.@group != ServerUsers.UserGroup.Banned)
            {
                arg.ReplyWith(string.Concat("User ", num, " isn't banned"));
                return;
            }
            ServerUsers.Remove(num);
            arg.ReplyWith(string.Concat("Unbanned User: ", num));
        }
Пример #16
0
 bool?CanRemove(BasePlayer player, BaseEntity entity)
 {
     if (player == null || entity == null)
     {
         return(null);
     }
     if (!entity.OwnerID.IsSteamId())
     {
         return(null);
     }
     if (PermissionService.HasPermission(player.userID, BAN_PERM))
     {
         if (bans.ContainsKey(entity.OwnerID) || ServerUsers.Get(entity.OwnerID)?.@group == ServerUsers.UserGroup.Banned)
         {
             return(true);
         }
     }
     return(null);
 }
Пример #17
0
        public static void banid(ConsoleSystem.Arg arg)
        {
            ulong  num  = arg.GetUInt64(0, (ulong)0);
            string str  = arg.GetString(1, "unnamed");
            string str1 = arg.GetString(2, "no reason");

            if (num < 70000000000000000L)
            {
                arg.ReplyWith(string.Concat("This doesn't appear to be a 64bit steamid: ", num));
                return;
            }
            ServerUsers.User user = ServerUsers.Get(num);
            if (user != null && user.@group == ServerUsers.UserGroup.Banned)
            {
                arg.ReplyWith(string.Concat("User ", num, " is already banned"));
                return;
            }
            ServerUsers.Set(num, ServerUsers.UserGroup.Banned, str, str1);
            arg.ReplyWith(string.Concat(new object[] { "Banned User: "******" - ", str }));
        }
Пример #18
0
        public static void ownerid(Arg arg)
        {
            ulong  uInt    = arg.GetUInt64(0, 0uL);
            string @string = arg.GetString(1, "unnamed");
            string string2 = arg.GetString(2, "no reason");

            if (uInt < 70000000000000000L)
            {
                arg.ReplyWith("This doesn't appear to be a 64bit steamid: " + uInt);
                return;
            }
            ServerUsers.User user = ServerUsers.Get(uInt);
            if (user != null && user.group == ServerUsers.UserGroup.Owner)
            {
                arg.ReplyWith("User " + uInt + " is already an Owner");
                return;
            }
            ServerUsers.Set(uInt, ServerUsers.UserGroup.Owner, @string, string2, -1L);
            arg.ReplyWith("Added owner " + @string + ", steamid " + uInt);
        }
Пример #19
0
        public static void banid(Arg arg)
        {
            ulong  uInt    = arg.GetUInt64(0, 0uL);
            string text    = arg.GetString(1, "unnamed");
            string @string = arg.GetString(2, "no reason");

            if (uInt < 70000000000000000L)
            {
                arg.ReplyWith("This doesn't appear to be a 64bit steamid: " + uInt);
                return;
            }
            ServerUsers.User user = ServerUsers.Get(uInt);
            if (user != null && user.group == ServerUsers.UserGroup.Banned)
            {
                arg.ReplyWith("User " + uInt + " is already banned");
            }
            else
            {
                long   expiry;
                string durationSuffix;
                if (!TryGetBanExpiry(arg, 3, out expiry, out durationSuffix))
                {
                    return;
                }
                string     text2      = "";
                BasePlayer basePlayer = BasePlayer.FindByID(uInt);
                if (basePlayer != null && basePlayer.IsConnected)
                {
                    text = basePlayer.displayName;
                    if (basePlayer.IsConnected && basePlayer.net.connection.ownerid != 0L && basePlayer.net.connection.ownerid != basePlayer.net.connection.userid)
                    {
                        text2 += $" and also banned ownerid {basePlayer.net.connection.ownerid}";
                        ServerUsers.Set(basePlayer.net.connection.ownerid, ServerUsers.UserGroup.Banned, basePlayer.displayName, arg.GetString(1, $"Family share owner of {basePlayer.net.connection.userid}"), expiry);
                    }
                    Chat.Broadcast("Kickbanning " + basePlayer.displayName + durationSuffix + " (" + @string + ")", "SERVER", "#eee", 0uL);
                    Network.Net.sv.Kick(basePlayer.net.connection, "Banned" + durationSuffix + ": " + @string);
                }
                ServerUsers.Set(uInt, ServerUsers.UserGroup.Banned, text, @string, expiry);
                arg.ReplyWith($"Banned User{durationSuffix}: {uInt} - \"{text}\" for \"{@string}\"{text2}");
            }
        }
Пример #20
0
        public static void unban(ConsoleSystem.Arg arg)
        {
            ulong uint64 = arg.GetUInt64(0, 0UL);

            if (uint64 < 70000000000000000UL)
            {
                arg.ReplyWith("This doesn't appear to be a 64bit steamid: " + (object)uint64);
            }
            else
            {
                ServerUsers.User user = ServerUsers.Get(uint64);
                if (user == null || user.group != ServerUsers.UserGroup.Banned)
                {
                    arg.ReplyWith("User " + (object)uint64 + " isn't banned");
                }
                else
                {
                    ServerUsers.Remove(uint64);
                    arg.ReplyWith("Unbanned User: " + (object)uint64);
                }
            }
        }
Пример #21
0
        private void ProcessBan(IPlayer player, JObject clan, string reason)
        {
            string reason1 = "CLAN BAN (" + clan["tag"] + ") : " + reason;

            foreach (var member in clan["members"])
            {
                var target = covalence.Players.FindPlayerById(Convert.ToString(member));
                if (type == 1)
                {
                    EnhancedBanSystem.Call("BanPlayer", player.Name, target, reason1, 0.0);
                }
                if (type == 2)
                {
                    var exists = ServerUsers.Get(ulong.Parse(target.Id));
                    if (exists != null && ServerUsers.Get(ulong.Parse(target.Id)).group == ServerUsers.UserGroup.Banned)
                    {
                        SendMessage(player, GetLang("AlreadyBanned", player.Id, target.Name));
                        return;
                    }
                    ServerUsers.Set(ulong.Parse(target.Id), ServerUsers.UserGroup.Banned, target.Name, reason1);
                    ServerUsers.Save();
                    server.Broadcast(GetLang("PlayerBanned", null, target.Name, reason));
                    if (target.IsConnected)
                    {
                        target.Kick(reason);
                    }
                }
                if (type == 3)
                {
                    DiscordMessages.Call("ExecuteBan", target, player, reason1);
                }
            }
            if (AnnounceToServer)
            {
                server.Broadcast(GetLang("BanMessage", null, clan["tag"], reason));
            }
        }
Пример #22
0
        public static void banid(ConsoleSystem.Arg arg)
        {
            ulong  uint64   = arg.GetUInt64(0, 0UL);
            string username = arg.GetString(1, "unnamed");
            string notes    = arg.GetString(2, "no reason");

            if (uint64 < 70000000000000000UL)
            {
                arg.ReplyWith("This doesn't appear to be a 64bit steamid: " + (object)uint64);
            }
            else
            {
                ServerUsers.User user = ServerUsers.Get(uint64);
                if (user != null && user.group == ServerUsers.UserGroup.Banned)
                {
                    arg.ReplyWith("User " + (object)uint64 + " is already banned");
                }
                else
                {
                    ServerUsers.Set(uint64, ServerUsers.UserGroup.Banned, username, notes);
                    arg.ReplyWith("Banned User: "******" - " + username);
                }
            }
        }
Пример #23
0
 public void GetUsername()
 {
     _plugin.webrequest.EnqueueGet(string.Format(SteamAPI_PastUsernameFormat, SteamID), (code, response) =>
     {
         if (code == 200)
         {
             List <SteamAlias_Ajax> lastNames;
             try
             {
                 lastNames = JsonConvert.DeserializeObject <List <SteamAlias_Ajax> >(response);
             }
             catch
             {
                 //_plugin.Puts("Failed to parse JSON GetUsername()");
                 Username = "******";
                 return;
             }
             if (lastNames.Count == 0)
             {
                 //_plugin.Puts($"GetUsername() returned no usernames for {SteamID}!");
                 Username = "******";
                 return;
             }
             Username = lastNames.First().newname;
             var user = ServerUsers.Get(SteamID);
             if (user != null)
             {
                 user.username = Username;
             }
         }
         else
         {
             _plugin.Puts($"GetUsername() error code: {code}");
         }
     }, _plugin, null, 60);
 }
Пример #24
0
        internal static bool sayAs(ChatChannel targetChannel, ulong userId, string username, string message, BasePlayer player = null)
        {
            if (!player)
            {
                player = null;
            }
            if (!enabled)
            {
                return(false);
            }
            if (player != null && player.HasPlayerFlag(BasePlayer.PlayerFlags.ChatMute))
            {
                return(false);
            }
            ServerUsers.UserGroup userGroup = ServerUsers.Get(userId)?.group ?? ServerUsers.UserGroup.None;
            if (userGroup == ServerUsers.UserGroup.Banned)
            {
                return(false);
            }
            string text = message.Replace("\n", "").Replace("\r", "").Trim();

            if (text.Length > 128)
            {
                text = text.Substring(0, 128);
            }
            if (text.Length <= 0)
            {
                return(false);
            }
            if (text.StartsWith("/") || text.StartsWith("\\"))
            {
                Interface.CallHook("IOnPlayerCommand", player, message);
                return(false);
            }
            text = text.EscapeRichText();
            object obj = Interface.CallHook("IOnPlayerChat", userId, username, text, targetChannel, player);

            if (obj is bool)
            {
                return((bool)obj);
            }
            if (serverlog)
            {
                ServerConsole.PrintColoured(ConsoleColor.DarkYellow, string.Concat("[", targetChannel, "] ", username, ": "), ConsoleColor.DarkGreen, text);
                string text2 = player?.ToString() ?? $"{username}[{userId}]";
                switch (targetChannel)
                {
                case ChatChannel.Team:
                    DebugEx.Log("[TEAM CHAT] " + text2 + " : " + text);
                    break;

                case ChatChannel.Cards:
                    DebugEx.Log("[CARDS CHAT] " + text2 + " : " + text);
                    break;

                default:
                    DebugEx.Log("[CHAT] " + text2 + " : " + text);
                    break;
                }
            }
            bool   flag  = userGroup == ServerUsers.UserGroup.Owner || userGroup == ServerUsers.UserGroup.Moderator;
            bool   num   = ((player != null) ? player.IsDeveloper : DeveloperList.Contains(userId));
            string text3 = "#5af";

            if (flag)
            {
                text3 = "#af5";
            }
            if (num)
            {
                text3 = "#fa5";
            }
            string    text4     = username.EscapeRichText();
            ChatEntry chatEntry = default(ChatEntry);

            chatEntry.Channel  = targetChannel;
            chatEntry.Message  = text;
            chatEntry.UserId   = ((player != null) ? player.UserIDString : userId.ToString());
            chatEntry.Username = username;
            chatEntry.Color    = text3;
            chatEntry.Time     = Epoch.Current;
            ChatEntry chatEntry2 = chatEntry;

            History.Add(chatEntry2);
            RCon.Broadcast(RCon.LogType.Chat, chatEntry2);
            switch (targetChannel)
            {
            case ChatChannel.Cards:
            {
                if (player == null)
                {
                    return(false);
                }
                if (!player.isMounted)
                {
                    return(false);
                }
                CardTable cardTable = player.GetMountedVehicle() as CardTable;
                if (cardTable == null || !cardTable.GameController.PlayerIsInGame(player))
                {
                    return(false);
                }
                List <Network.Connection> obj2 = Facepunch.Pool.GetList <Network.Connection>();
                cardTable.GameController.GetConnectionsInGame(obj2);
                if (obj2.Count > 0)
                {
                    ConsoleNetwork.SendClientCommand(obj2, "chat.add2", 3, userId, text, text4, text3, 1f);
                }
                Facepunch.Pool.FreeList(ref obj2);
                return(true);
            }

            case ChatChannel.Global:
                if (Server.globalchat)
                {
                    ConsoleNetwork.BroadcastToAllClients("chat.add2", 0, userId, text, text4, text3, 1f);
                    return(true);
                }
                break;

            case ChatChannel.Team:
            {
                RelationshipManager.PlayerTeam playerTeam = RelationshipManager.ServerInstance.FindPlayersTeam(userId);
                if (playerTeam == null)
                {
                    return(false);
                }
                List <Network.Connection> onlineMemberConnections = playerTeam.GetOnlineMemberConnections();
                if (onlineMemberConnections != null)
                {
                    ConsoleNetwork.SendClientCommand(onlineMemberConnections, "chat.add2", 1, userId, text, text4, text3, 1f);
                }
                Util.BroadcastTeamChat(playerTeam, userId, text4, text, text3);
                return(true);
            }
            }
            if (player != null)
            {
                float num2 = 2500f;
                foreach (BasePlayer activePlayer in BasePlayer.activePlayerList)
                {
                    float sqrMagnitude = (activePlayer.transform.position - player.transform.position).sqrMagnitude;
                    if (!(sqrMagnitude > num2))
                    {
                        ConsoleNetwork.SendClientCommand(activePlayer.net.connection, "chat.add2", 0, userId, text, text4, text3, Mathf.Clamp01(num2 - sqrMagnitude + 0.2f));
                    }
                }
                return(true);
            }
            return(false);
        }