Welcome, Guest Friday 18th April 2014, 17:49:43
   Home   Help Search Login Register  

OFPEC Forum

Author Topic: Filter?  (Read 284 times)
0 Members and 1 Guest are viewing this topic.
ModestNovice
*
Offline Offline


« on: 23 Dec 2008, 05:02:16 »

is there a way to check for profanity in a message typed into a input box?

Im adding a thing to my mission that allows players to make there own messages, but I dont want them writing nonsense.

Any ideas??
Logged

"The road became empty and the people disappeared. The clouds ran away; opened up the sky, and one by one I watched every constellation die."
- Sean "Slug" Daley
Luke
*
Offline Offline

Thank God! The OFPEC Staff are here!


« Reply #1 on: 24 Dec 2008, 05:18:18 »

only if you can find a way to screen each word, which as far as I know, is impossible.

If you could only type one word at a time then run them through a filter,
but only exact matches would work, so 'ass' would be filtered,
but not 'jackass' unless you add it to the list of words it checks for,
and the list of english profane euphimisms and explitives is a long one.

Plus, if you don't have it one word at a time, then the whole block is a string, much like this entire message.

And I do not belive you can subdivide strings.

Valiant effort, Mr. Chevs, but to my knowledge, impossible.

Luke
Logged

Pesky Human!!
Wort Wort Wort.
ModestNovice
*
Offline Offline


« Reply #2 on: 24 Dec 2008, 06:05:40 »

Righto thats what I thought, but was hoping otherwise lol.

Thanks for the info Luke  Wink
Logged

"The road became empty and the people disappeared. The clouds ran away; opened up the sky, and one by one I watched every constellation die."
- Sean "Slug" Daley
Mandoble
Editors Depot
Administrator
*****
Offline Offline



WWW
« Reply #3 on: 24 Dec 2008, 09:31:11 »

You can, but it is a bit tricky.
First you set your "bad words" array in the following way.
Code:
_bad_words_strings = ["hello", "bye"];
bad_words_array = [];

{
   _temp_array = to_array _x;
   bad_words_array = bad_words_array + [_temp_array];
} forEach _bad_words_strings;

Then, once you have a string in an editbox of anywhere else you need to split it into words, for example, looking for spaces:

Code:
_word = [];
// _string has your edit control string.
_full_array = to_array _string;
for [{_i=0},{_i<count _full_array},{_i=_i+1}] do
{
// This quite basic example uses 32 (space) as indication that a word is finished.
   if (_x != 32) then
   {
      _word = _word + [_full_array select _i];
   }
   else
   {
      if (_word in bad_words_array) then
      {
         hint "BAD WORD DETECTED";
      };
      _word = [];
   };
};

if (count _word > 0) then
{
   if (_word in bad_words_array) then
   {
      hint "BAD WORD DETECTED";
   };
};
Logged

Luke
*
Offline Offline

Thank God! The OFPEC Staff are here!


« Reply #4 on: 24 Dec 2008, 17:48:06 »

Using keydown dawned on me last night, sorry about that Chevs.

Anyway Mando brings a valid point, but also instead of just finding the bad words,
how would you go about deleting the word before it was sent?

Luke
Logged

Pesky Human!!
Wort Wort Wort.
Mandoble
Editors Depot
Administrator
*****
Offline Offline



WWW
« Reply #5 on: 24 Dec 2008, 18:46:57 »

You can remove the bad words before sending the message, but why? If you remove them and send the remaining message, more than probably that resulting message will be a total nonsense.
Logged

Luke
*
Offline Offline

Thank God! The OFPEC Staff are here!


« Reply #6 on: 25 Dec 2008, 03:24:47 »

Simply replace the word with either '###' or,
depending on DaChevs' sense of humour, a more comical string of symbols.

ie '$#!!", '@$$' '#^$*' etc.

Plus if space is used to detect those words, compound words won't be detected:
ie 'Jackass'.

Luke
Logged

Pesky Human!!
Wort Wort Wort.
ModestNovice
*
Offline Offline


« Reply #7 on: 26 Dec 2008, 00:53:34 »

haha Luke, right :/


I had been trying with to array, converting the message with toArray, but didnt know what to do afterwards lol. This now makes more sense. Thanks you two Smiley
Logged

"The road became empty and the people disappeared. The clouds ran away; opened up the sky, and one by one I watched every constellation die."
- Sean "Slug" Daley
Pages: [1]   Go Up
  Send this topicPrint  
 
Jump to: