Word Filter 2d

You are here:
← All Topics
Version: 2019.100 Requirements:uMMORPG2d, ToolsScript Define:_IMMOUSAGEREQUIREMENTS
Core Changes:YesTutorial Video:No

Description

Filters both character names and chat messages for bad words and denies them if they contain those (blocks the name from being used or the message from being sent). You can maintain a list of “bad words” that is used in both cases.


Core Changes

  1. [Required] Open the following script NetworkManagerMMO.cs. See Changes...

    Comment Out/Delete this line:
        public bool IsAllowedCharacterName(string characterName)
        {
            // not too long?
            // only contains letters, number and underscore and not empty (+)?
            // (important for database safety etc.)
            return characterName.Length <= characterNameMaxLength &&
                   Regex.IsMatch(characterName, @"^[a-zA-Z0-9_]+$");
        }
  2. [Required] Open the following script PlayerChat.cs. See Changes...

    Locate this line:
    if (!string.IsNullOrWhiteSpace(text))

    Modify to match:

    if (UCE_IsAllowedChatText(text))

Installation

  1. [Required] Create a new “Wordfilter” list via the context menu.
  2. [Required] Add all words to the list you want to ban from both chat and character names.
  3. [Required] Select NetworkManager in your scene and add the Wordfilter object to the new slot in the inspector.
  4. [Required] Select the Chat component on each one of your player prefabs and add the Wordfilter object to the new slot in the inspector.

Screenshot


Extra

  • When a bad word is contained the character will not be created, the player gets a popup with “error”, thats all.
  • When a chat message contains a bad word, the message is not being sent. That also reduces network bandwith.

Support the IndieMMO Team Today!

Leave a reply

This site uses Akismet to reduce spam. Learn how your comment data is processed.