Home   Help Search Login Register  

Author Topic: Filter?  (Read 1705 times)

0 Members and 1 Guest are viewing this topic.

Offline ModestNovice

  • Members
  • *
Filter?
« 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??
"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

Offline Luke

  • Members
  • *
  • Thank God! The OFPEC Staff are here!
Re: Filter?
« 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
Pesky Human!!
Wort Wort Wort.

Offline ModestNovice

  • Members
  • *
Re: Filter?
« Reply #2 on: 24 Dec 2008, 06:05:40 »
Righto thats what I thought, but was hoping otherwise lol.

Thanks for the info Luke  ;)
"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

Offline Mandoble

  • Former Staff
  • ****
    • Grunt ONE and MandoMissile suite
Re: Filter?
« 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: [Select]
_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: [Select]
_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";
   };
};

Offline Luke

  • Members
  • *
  • Thank God! The OFPEC Staff are here!
Re: Filter?
« 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
Pesky Human!!
Wort Wort Wort.

Offline Mandoble

  • Former Staff
  • ****
    • Grunt ONE and MandoMissile suite
Re: Filter?
« 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.

Offline Luke

  • Members
  • *
  • Thank God! The OFPEC Staff are here!
Re: Filter?
« 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
Pesky Human!!
Wort Wort Wort.

Offline ModestNovice

  • Members
  • *
Re: Filter?
« 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 :)
"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