Ulysses Stuff > Releases

CenKik - Censoring and Kicking

<< < (4/11) > >>

MrPresident:
Take a look at:

http://maurits.tv/data/garrysmod/wiki/wiki.garrysmod.com/index53ea.html

it would be like:

--- Code: ---mytable = string.Explode( " ", message ) --this takes the string message and separates it into a table with space as the separator.
for k, v in pairs(mytable) do
--run your loop to check v against the table of unallowed words
--if the word should be censored then change the table value like this
mytable[v] == "*****"
end
newmessage = string.Implode( " ", mytable ) --this takes the table and places it back into a string with space as the separator.

--- End code ---

If someone types: "This forum is great and I love everyone here"
and "great" is an unallowed word it would censor it and output
"This forum is ***** and I love everyone here"

MrPresident:
The benefit of doing it this way is that each word is checked as a separate string, allowing you to modify individual words and not having to convert the whole string into lowercase or whatever.

Neku:
UPDATE: All string lowercase fixed. Thanks, MrPresident!

NEW BUG: Letters attached to the censored word will be in lowercase.

Neku:

--- Quote from: MrPresident on January 15, 2014, 06:57:43 PM ---
--- Code: ---mytable = string.Explode( " ", message ) --this takes the string message and separates it into a table with space as the separator.
for k, v in pairs(mytable) do
--run your loop to check v against the table of unallowed words
--if the word should be censored then change the table value like this
mytable[v] == "*****"
end
newmessage = string.Implode( " ", mytable ) --this takes the table and places it back into a string with space as the separator.

--- End code ---

--- End quote ---

Instead of v, I used k because v gives us the value instead of the table's index.

MrPresident:
Yep, sorry. My bad. You would indeed use k.

Navigation

[0] Message Index

[#] Next page

[*] Previous page

Go to full version