[Solved] How do I create a profanity filter for a textbox

Get help using Construct 2

Post » Thu Nov 27, 2014 9:07 am

Greetings

I am currently working on a scoreboard and I would like to find a elegant way to implement a profanity filter. Right now I am using a lot of variables (so that I can change it afterwards).

It is horrible :|
You do not have the required permissions to view the files attached to this post.
Last edited by Je Fawk on Fri Nov 28, 2014 1:24 pm, edited 1 time in total.
Black Bobby The Hole Greenlit with 303 votes.
B
35
S
8
G
1
Posts: 163
Reputation: 2,979

Post » Fri Nov 28, 2014 8:46 am

Any ideas?
Black Bobby The Hole Greenlit with 303 votes.
B
35
S
8
G
1
Posts: 163
Reputation: 2,979

Post » Fri Nov 28, 2014 1:23 pm

Nevermind, I found it myself.

Here's a screenshot for anyone looking for something similar.

profanity filter.jpg
You do not have the required permissions to view the files attached to this post.
Black Bobby The Hole Greenlit with 303 votes.
B
35
S
8
G
1
Posts: 163
Reputation: 2,979

Post » Fri Nov 28, 2014 1:52 pm

You should also check if part of the name matches each key. You can do that by checking if find(scorePlayerName.Text, ProfanityFilterDictionary.CurrentValue) is different from -1. If it is, it means the key is included in that player's name and should be filtered, if it is equal to -1 the key was not found and the name is fine.

For example:
Your method would detect if a player used "Fuck" as name, but would not detect if he used "Fuck1"

The find method above would return 0 for both "Fuck" and "Fuck1", meaning the key was found and should be filtered. :)


Also, you should save all keys in lowercase and test the lowercase(scorePlayerName.Text) against them. This would avoid players from getting away with it by writing "fUcK" for instance.
Last edited by brunopalermo on Fri Nov 28, 2014 1:55 pm, edited 1 time in total.
Bruno

I like to eat, but I'm no cook. Why liking to play games would make you a game designer?
B
15
S
3
G
1
Posts: 329
Reputation: 2,012

Post » Fri Nov 28, 2014 1:53 pm

I wasn't aware that is possible :3

Thanks!
Black Bobby The Hole Greenlit with 303 votes.
B
35
S
8
G
1
Posts: 163
Reputation: 2,979

Post » Fri Nov 28, 2014 1:56 pm

Oh. I didn't notice the check you make is "case insensitive". Duh! :)
Bruno

I like to eat, but I'm no cook. Why liking to play games would make you a game designer?
B
15
S
3
G
1
Posts: 329
Reputation: 2,012

Post » Fri Nov 28, 2014 1:57 pm

@brunopalermo The usage of the find function is still really useful ^^
Black Bobby The Hole Greenlit with 303 votes.
B
35
S
8
G
1
Posts: 163
Reputation: 2,979

Post » Fri Nov 28, 2014 2:58 pm

Glad to help!
Bruno

I like to eat, but I'm no cook. Why liking to play games would make you a game designer?
B
15
S
3
G
1
Posts: 329
Reputation: 2,012

Post » Fri Nov 28, 2014 7:46 pm

A quick addition: trim.
Black Bobby The Hole Greenlit with 303 votes.
B
35
S
8
G
1
Posts: 163
Reputation: 2,979


Return to How do I....?

Who is online

Users browsing this forum: Cha0tiXGamer, MaujDeveloper and 9 guests