OFPEC Forum
Editors Depot - Mission Editing and Scripting => ArmA - Editing/Scripting General => Topic started by: ModestNovice 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??
-
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
-
Righto thats what I thought, but was hoping otherwise lol.
Thanks for the info Luke ;)
-
You can, but it is a bit tricky.
First you set your "bad words" array in the following way.
_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:
_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";
};
};
-
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
-
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.
-
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
-
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 :)