Beispiel #1
0
        void OnPlayerChat(PlayerEvent e)
        {
            List <string> ForbiddenWordsList = Config["ForbiddenWords"] as List <string>;
            Player        player             = e.Player;
            string        message            = e.ToString();
            string        censored           = "";
            bool          isCensored         = false;

            if (message.StartsWith("/"))
            {
                return;
            }
            foreach (string word in ForbiddenWordsList)
            {
                censored = "";
                for (int i = 0; i < word.Length; i++)
                {
                    censored = censored + "*";
                }

                if (message.ToLower().Contains(word.ToLower()))
                {
                    message    = message.ToLower().Replace(word.ToLower(), censored);
                    isCensored = true;
                }
            }
            if (isCensored)
            {
                BroadcastChat(player.DisplayName, message);
                e.Cancel();
            }
        }
Beispiel #2
0
 private void OnPlayerChat(PlayerEvent e)
 {
     if (e is PlayerChatEvent)
     {
         var chat = (PlayerChatEvent)e;
         if (mutedPlayers.Contains(chat.Player.Id.ToString()))
         {
             PrintToChat(chat.Player, "You are muted.");
             e.Cancel("Player is Muted");
         }
     }
 }
Beispiel #3
0
        void OnPlayerChat(PlayerEvent e)
        {
            List <string> ForbiddenWordsList = Config["ForbiddenWords"] as List <string>;
            Player        player             = e.Player;
            string        message            = e.ToString();
            string        censored           = "";
            bool          isCensored         = false;

            if (message.StartsWith("/"))
            {
                return;
            }

            string filteredMessage = GetFilteredMesssage(message);

            if (message != filteredMessage)
            {
                BroadcastChat(player.DisplayName, filteredMessage);
                e.Cancel();
            }
        }