[SOLVED] Script for banning bad words & offensive content?

So I'm working on my game, and I know that a lot of players are going to be entering stupid stuff when naming the player. I've tried using Conditional Branches but I know that's gonna take way too long, even though I've done it before when I used RPG Maker 2000 but I just can't redo all the hard work in another engine.

EDIT Dang it... I forgot to put this in the Script requests... 😔
No problem, I'll move it for you. 🙂

I've moved this thread to RGSS3 Script Requests. Thank you.

I haven't seen a script for this, but someone else might have.

Just as a quick aside...what difference does it make to you what players name their characters? Have you implemented something for some kind of online functionality where other people could see those names? If not, how does it matter?
I'm gonna name my character Booby McBoobFace whether you like it or not.

Profanity filters and the like are kinda pointless in my opinion. I like how in Fallout 4 they leaned into it and had Cogsworth able to say the player name even if they named themselves something dumb like:
Code:
A*sface
Bada*s
Boob
Boobie
Boobies
Cherrybomb
Cock
Cockerham
Dong
Erectus
F*cker
F*ckface
Goose
Humongous
Humongus
Jeff
Loner
Markiepoo
Monster
Mudguts
Nipple
ORGASMO
Psycho
Sweetpea
Tit
Tittie
Toast
Willy
Try this:
Banned Names
Instead of banning words I would go the different path of having a whitelist of permissible names. Maybe I'll have like 3-10 different names to choose from.
I experimented with this and it it is really pretty easy. I don't know what the script would be for XP, but here is an example from MZ using Java Script.

if ($gameActors.actor(1).name().toLowerCase().includes("balls") ||
$gameActors.actor(1).name().toLowerCase().includes("") ||
$gameActors.actor(1).name().toLowerCase().includes("wimp")) {
$gameVariables.setValue(5, 2);

}

Essentially, you can add as many of these check lines as you want. For my experiment, I think I had close to 100. It was interesting trying to brainstorm content to exclude and it looks rather funny as one long script.

I am using a simple Variable value to determine if the name is ok or not. If the value is "2" like in the example above, whatever they typed in contains an unacceptable word or partial word. Otherwise the name is good to go.

Again, I don't know how this translates to whatever XP uses.

And I thought about this a bit too. Unless you advertise it to the player, many would never know that this sort of name check even exists.

Anyway, good luck!
I haven't seen a script for this, but someone else might have.

Just as a quick aside...what difference does it make to you what players name their characters? Have you implemented something for some kind of online functionality where other people could see those names? If not, how does it matter?
It's mainly because my friends might name the character something brainrotten or offensive.
I'm gonna name my character Booby McBoobFace whether you like it or not.

Profanity filters and the like are kinda pointless in my opinion. I like how in Fallout 4 they leaned into it and had Cogsworth able to say the player name even if they named themselves something dumb like:
Code:
A*sface
Bada*s
Boob
Boobie
Boobies
Cherrybomb
Cock
Cockerham
Dong
Erectus
F*cker
F*ckface
Goose
Humongous
Humongus
Jeff
Loner
Markiepoo
Monster
Mudguts
Nipple
ORGASMO
Psycho
Sweetpea
Tit
Tittie
Toast
Willy
I was thinking banning more of the ethnic slurs and Gen Alpha slang.
Have you considered a Eula for your game? In your End User License Agreement, you can list all of the alphanumeric strings that characters many NOT be called. If they do, and you find out, you can sue them for breech of contract, or disable their game within the allowances of your agreement.
Have you considered a Eula for your game? In your End User License Agreement, you can list all of the alphanumeric strings that characters many NOT be called. If they do, and you find out, you can sue them for breech of contract, or disable their game within the allowances of your agreement.
Uh... I don't think I want to go that far into suing someone over naming themselves something stupid, I just personally don't like people saying Gen Alpha slang and offensive things.
Uh... I don't think I want to go that far into suing someone over naming themselves something stupid, I just personally don't like people saying Gen Alpha slang and offensive things.
Have you tried the script i wrote for you? Is it working for you? If so then your problem is solved ^^
It's mainly because my friends might name the character something brainrotten or offensive.
Offensive to whom? This doesn't address my question at all - exactly who can see these character names and be offended by them?

Aren't you concerned that your friends might sit in their room writing racial slurs and curse words down in notebooks? Better find some way to stop them from doing that, too 🤣

Don't get me wrong, you do whatever you want in your game, this just seems like a silly thing to spend any time or effort on.

Have you considered a Eula for your game? In your End User License Agreement, you can list all of the alphanumeric strings that characters many NOT be called. If they do, and you find out, you can sue them for breech of contract, or disable their game within the allowances of your agreement.
That's a terrible idea. For one thing, logically, it's forcing anyone who reads the agreement to read the very words the OP doesn't want people exposed to.

For another, it's completely legally unenforceable, even if you had the monetary means to sue people casually (which most people don't). I'd bet you a doughnut that if it got to a court, the judge would toss it for wasting their time.
I can see a system like this being really useful in a game intended for a younger audience--I can't imagine it would be a nice look if you made a game that was supposed to be for nine-year-olds and someone posted screenshots of their character with a name that is generally not considered appropriate for use around nine-year-olds XD Someone familiar with the idea of being able to name the characters in the game would know that that wasn't something that was strictly supposed to be in there, but someone who isn't familiar with that idea might get the wrong impression. Disallowing them seems like an erring-on-the-side-of-caution thing, to me.

(I'm aware most people here aren't developing games for nine-year-olds, but still--I was, at one point, so perhaps someone else is too.)
or you can go the South Park way and subvert the naming altogether.
in Stick Of Truth, you're forced to come out of the character creation screen as "Douchebag"
Have you tried the script i wrote for you? Is it working for you? If so then your problem is solved ^^

Can you make there an option to toggle a switch or/and a common event when the player names themselves something on the list?
I feel like you are making the game to be exclusively played by your friends, and you expect them to do this just to bug you. In that case banning would be a great inside joke and the perfect premeditated revenge. You can even add a taunting message when they try a banned name. But I wouldn't do this in a public game, though.

As a random player, if this would happen to me before I got sucked into the game, I would already be done with it. Specially if I tried 2 or 3 names. Or what of a youtuber wants to stream your game, and their accountname is banned because it has a dirty word?

If it is a public game, then you can encourage your friends to use their real name or nickname. You could put special inside jokes in the game that no-one else would get, which only appear if actor 1 is named exactly the way you told your friend to name themselves.
Can you make there an option to toggle a switch or/and a common event when the player names themselves something on the list?
I can't see what IneptAttourney_08 wrote but I just made this.
Does it need a switch or CE?
Spoiler: Bad Names
Ruby:
# ╔═══════════════════════════════════════════════╦════════════════════╗
# ║ Title: Bad Names                              ║  Version: 1.00     ║
# ║ Author: Roninator2                            ║                    ║
# ╠═══════════════════════════════════════════════╬════════════════════╣
# ║ Function:                                     ║   Date Created     ║
# ║                                               ╠════════════════════╣
# ║   Prevent using bad words                     ║    04 Jul 2024     ║
# ╚═══════════════════════════════════════════════╩════════════════════╝
# ╔════════════════════════════════════════════════════════════════════╗
# ║ Requires: nil                                                      ║
# ║                                                                    ║
# ╚════════════════════════════════════════════════════════════════════╝
# ╔════════════════════════════════════════════════════════════════════╗
# ║ Brief Description:                                                 ║
# ║       Stops the use of pre defined words when naming actors        ║
# ╚════════════════════════════════════════════════════════════════════╝
# ╔════════════════════════════════════════════════════════════════════╗
# ║ Instructions:                                                      ║
# ║   Enter in words to stop the player from using below               ║
# ║   Enter in the message to show when aba d name is used             ║
# ╚════════════════════════════════════════════════════════════════════╝
# ╔════════════════════════════════════════════════════════════════════╗
# ║ Updates:                                                           ║
# ║ 1.00 - 04 Jul 2024 - Script finished                               ║
# ║                                                                    ║
# ╚════════════════════════════════════════════════════════════════════╝
# ╔════════════════════════════════════════════════════════════════════╗
# ║ Credits and Thanks:                                                ║
# ║   Roninator2                                                       ║
# ║                                                                    ║
# ╚════════════════════════════════════════════════════════════════════╝
# ╔════════════════════════════════════════════════════════════════════╗
# ║ Terms of use:                                                      ║
# ║  Follow the original Authors terms of use where applicable         ║
# ║    - When not made by me (Roninator2)                              ║
# ║  Free for all uses in RPG Maker except nudity                      ║
# ║  Anyone using this script in their project before these terms      ║
# ║  were changed are allowed to use this script even if it conflicts  ║
# ║  with these new terms. New terms effective 03 Apr 2024             ║
# ║  No part of this code can be used with AI programs or tools        ║
# ║  Credit must be given                                              ║
# ╚════════════════════════════════════════════════════════════════════╝

module R2_Bad_Names
 
  BAD_NAMES = ["Word","Capital","lowercase",
              "friend","aa",
              "Badman","Other",
              # add whatever
              ]
  MESSAGE = "That is a completely unacceptable name to use"
end

# ╔════════════════════════════════════════════════════════════════════╗
# ║                      End of editable region                        ║
# ╚════════════════════════════════════════════════════════════════════╝

#==============================================================================
# ** Window_BadName
#==============================================================================

class Window_BadName < Window_Selectable
  #--------------------------------------------------------------------------
  # * Object Initialization
  #--------------------------------------------------------------------------
  def initialize
    super(0, Graphics.height / 2, Graphics.width, fitting_height(2))
    self.hide
  end
  #--------------------------------------------------------------------------
  # * Refresh
  #--------------------------------------------------------------------------
  def refresh
    contents.clear
    draw_text_ex(0, 0, R2_Bad_Names::MESSAGE)
  end
  #--------------------------------------------------------------------------
  # * Handling Processing for OK and Cancel Etc.
  #--------------------------------------------------------------------------
  def process_handling
    return unless open? && active
    return process_cancel   if Input.trigger?(:B)
  end
  #--------------------------------------------------------------------------
  # * Call OK Handler
  #--------------------------------------------------------------------------
  def call_okay_handler
    call_handler(:okay)
  end
  #--------------------------------------------------------------------------
  # * Processing When Cancel Button Is Pressed
  #--------------------------------------------------------------------------
  def process_cancel
    call_okay_handler
  end
end

#==============================================================================
# ** Scene_Name
#==============================================================================

class Scene_Name < Scene_MenuBase
  #--------------------------------------------------------------------------
  # * Start Processing
  #--------------------------------------------------------------------------
  def start
    super
    @actor = $game_actors[@actor_id]
    @edit_window = Window_NameEdit.new(@actor, @max_char)
    @input_window = Window_NameInput.new(@edit_window)
    @input_window.set_handler(:ok, method(:on_input_ok))
    @message_box = Window_BadName.new
    @message_box.set_handler(:okay, method(:on_message_ok))
  end
  #--------------------------------------------------------------------------
  # * Input [OK]
  #--------------------------------------------------------------------------
  def on_input_ok
    if name_good
      @actor.name = @edit_window.name
      return_scene
    else
      kill_name
    end
  end
  #--------------------------------------------------------------------------
  # * Decide if Name is good
  #--------------------------------------------------------------------------
  def name_good
    name = @edit_window.name.downcase
    list = R2_Bad_Names::BAD_NAMES
    list.each do |nm|
      return false if nm.downcase == name
    end
    return true
  end
  #--------------------------------------------------------------------------
  # * prevent accepting name
  #--------------------------------------------------------------------------
  def kill_name
    @input_window.deactivate
    @message_box.show
    @message_box.activate
    @message_box.refresh
  end
  #--------------------------------------------------------------------------
  # * Message [OK]
  #--------------------------------------------------------------------------
  def on_message_ok
    @message_box.deactivate
    @message_box.hide
    @edit_window.restore_default
    @input_window.activate
  end
end
I know this might sound silly, but have you considered just not letting the player rename a character? Or you could give a list of names to choose from if you want to let them give some personality to their game.

I didn't do it for this reason, but one of my games gave the player a choice of one written character (letter, number, symbol, whatever). The main actor was a robot named something like TILOX- and the chosen character is added to the end. I mostly did it because I like being able to differentiate save files but it quickly became a cute feature the testplayers loved. You could adapt this idea to help prevent abuse.
I can't see what IneptAttourney_08 wrote but I just made this.
Does it need a switch or CE?
Spoiler: Bad Names
Ruby:
# ╔═══════════════════════════════════════════════╦════════════════════╗
# ║ Title: Bad Names                              ║  Version: 1.00     ║
# ║ Author: Roninator2                            ║                    ║
# ╠═══════════════════════════════════════════════╬════════════════════╣
# ║ Function:                                     ║   Date Created     ║
# ║                                               ╠════════════════════╣
# ║   Prevent using bad words                     ║    04 Jul 2024     ║
# ╚═══════════════════════════════════════════════╩════════════════════╝
# ╔════════════════════════════════════════════════════════════════════╗
# ║ Requires: nil                                                      ║
# ║                                                                    ║
# ╚════════════════════════════════════════════════════════════════════╝
# ╔════════════════════════════════════════════════════════════════════╗
# ║ Brief Description:                                                 ║
# ║       Stops the use of pre defined words when naming actors        ║
# ╚════════════════════════════════════════════════════════════════════╝
# ╔════════════════════════════════════════════════════════════════════╗
# ║ Instructions:                                                      ║
# ║   Enter in words to stop the player from using below               ║
# ║   Enter in the message to show when aba d name is used             ║
# ╚════════════════════════════════════════════════════════════════════╝
# ╔════════════════════════════════════════════════════════════════════╗
# ║ Updates:                                                           ║
# ║ 1.00 - 04 Jul 2024 - Script finished                               ║
# ║                                                                    ║
# ╚════════════════════════════════════════════════════════════════════╝
# ╔════════════════════════════════════════════════════════════════════╗
# ║ Credits and Thanks:                                                ║
# ║   Roninator2                                                       ║
# ║                                                                    ║
# ╚════════════════════════════════════════════════════════════════════╝
# ╔════════════════════════════════════════════════════════════════════╗
# ║ Terms of use:                                                      ║
# ║  Follow the original Authors terms of use where applicable         ║
# ║    - When not made by me (Roninator2)                              ║
# ║  Free for all uses in RPG Maker except nudity                      ║
# ║  Anyone using this script in their project before these terms      ║
# ║  were changed are allowed to use this script even if it conflicts  ║
# ║  with these new terms. New terms effective 03 Apr 2024             ║
# ║  No part of this code can be used with AI programs or tools        ║
# ║  Credit must be given                                              ║
# ╚════════════════════════════════════════════════════════════════════╝

module R2_Bad_Names
 
  BAD_NAMES = ["Word","Capital","lowercase",
              "friend","aa",
              "Badman","Other",
              # add whatever
              ]
  MESSAGE = "That is a completely unacceptable name to use"
end

# ╔════════════════════════════════════════════════════════════════════╗
# ║                      End of editable region                        ║
# ╚════════════════════════════════════════════════════════════════════╝

#==============================================================================
# ** Window_BadName
#==============================================================================

class Window_BadName < Window_Selectable
  #--------------------------------------------------------------------------
  # * Object Initialization
  #--------------------------------------------------------------------------
  def initialize
    super(0, Graphics.height / 2, Graphics.width, fitting_height(2))
    self.hide
  end
  #--------------------------------------------------------------------------
  # * Refresh
  #--------------------------------------------------------------------------
  def refresh
    contents.clear
    draw_text_ex(0, 0, R2_Bad_Names::MESSAGE)
  end
  #--------------------------------------------------------------------------
  # * Handling Processing for OK and Cancel Etc.
  #--------------------------------------------------------------------------
  def process_handling
    return unless open? && active
    return process_cancel   if Input.trigger?(:B)
  end
  #--------------------------------------------------------------------------
  # * Call OK Handler
  #--------------------------------------------------------------------------
  def call_okay_handler
    call_handler(:okay)
  end
  #--------------------------------------------------------------------------
  # * Processing When Cancel Button Is Pressed
  #--------------------------------------------------------------------------
  def process_cancel
    call_okay_handler
  end
end

#==============================================================================
# ** Scene_Name
#==============================================================================

class Scene_Name < Scene_MenuBase
  #--------------------------------------------------------------------------
  # * Start Processing
  #--------------------------------------------------------------------------
  def start
    super
    @actor = $game_actors[@actor_id]
    @edit_window = Window_NameEdit.new(@actor, @max_char)
    @input_window = Window_NameInput.new(@edit_window)
    @input_window.set_handler(:ok, method(:on_input_ok))
    @message_box = Window_BadName.new
    @message_box.set_handler(:okay, method(:on_message_ok))
  end
  #--------------------------------------------------------------------------
  # * Input [OK]
  #--------------------------------------------------------------------------
  def on_input_ok
    if name_good
      @actor.name = @edit_window.name
      return_scene
    else
      kill_name
    end
  end
  #--------------------------------------------------------------------------
  # * Decide if Name is good
  #--------------------------------------------------------------------------
  def name_good
    name = @edit_window.name.downcase
    list = R2_Bad_Names::BAD_NAMES
    list.each do |nm|
      return false if nm.downcase == name
    end
    return true
  end
  #--------------------------------------------------------------------------
  # * prevent accepting name
  #--------------------------------------------------------------------------
  def kill_name
    @input_window.deactivate
    @message_box.show
    @message_box.activate
    @message_box.refresh
  end
  #--------------------------------------------------------------------------
  # * Message [OK]
  #--------------------------------------------------------------------------
  def on_message_ok
    @message_box.deactivate
    @message_box.hide
    @edit_window.restore_default
    @input_window.activate
  end
end
It needs a switch, because I got a better plan in mind, but I was able to replace:
Ruby:
def kill_name
    @input_window.deactivate
    @message_box.show
    @message_box.activate
    @message_box.refresh
  end

with:
Ruby:
def kill_name
    $game_switches[26] = true
    @actor.name = @edit_window.name
    return_scene
  end

and was able to trigger a Conditional Event that checks to see if Switch No. #0026 is ON right after Name Input.

I'll make sure to mark this thread as solved.
This thread is closed due to being reported as solved. If you need it reopened, let us know. Thank you!

Original thread: https://forums.rpgmakerweb.com/threads/solved-script-for-banning-bad-words-offensive-content.169798/