Exemple #1
0
        void cmdChatMutes(BasePlayer player, string command, string[] args)
        {
            if (args.Length > 1)
            {
                player.ChatMessage(m_configData.Messages["invalid_arguments"]);
                return;
            }

            List <ulong> contextPlayers = new List <ulong>();

            foreach (ulong userID in m_configData.MutedPlayers.Keys)
            {
                string playerName = PlayerName(userID);
                if (args.Length == 1 && !playerName.Contains(args[0], System.Globalization.CompareOptions.IgnoreCase))
                {
                    continue;
                }

                MuteItem muteItem = m_configData.MutedPlayers[userID];
                contextPlayers.Add(userID);

                string message = m_configData.Messages["player_was_muted"];
                message = message.Replace("%player_name", playerName);
                message = message.Replace("%player_steamid", userID.ToString());
                message = message.Replace("%reason", muteItem.reason);
                message = message.Replace("%until_datetime", muteItem.untilDatetime().ToString("yyyy-MM-dd HH:mm:ss"));
                message = message.Replace("%level", m_configData.Messages[muteItem.level.ToString()]);

                player.ChatMessage(contextPlayers.Count.ToString() + ") " + muteItem.timestamp + " " + message);
            }
            SetContextPlayers(player.userID, contextPlayers);
        }
Exemple #2
0
        object OnPlayerChat(ConsoleSystem.Arg arg)
        {
            BasePlayer player = arg.Player();

            string message = "";

            foreach (string line in arg.Args)
            {
                message += line + " ";
            }
            message = message.Trim();

            if (m_configData.MutedPlayers.ContainsKey(player.userID))
            {
                MuteItem muteItem = m_configData.MutedPlayers[player.userID];

                if (muteItem.untilDatetime() > DateTime.Now)
                {
                    message = m_configData.Messages["player_was_muted"];
                    message = message.Replace("%player_name", player.displayName);
                    message = message.Replace("%player_steamid", player.userID.ToString());
                    message = message.Replace("%reason", muteItem.reason);
                    message = message.Replace("%until_datetime", muteItem.untilDatetime().ToString("yyyy-MM-dd HH:mm:ss"));
                    message = message.Replace("%level", m_configData.Messages[muteItem.level.ToString()]);

                    player.ChatMessage(message);
                    return("handled");
                }
            }

            if (message != "" && message[0] != '/')
            {
                NotifyPlayerChatMessage(player.userID, player.displayName, message);
            }

            return(null);
        }