I have a table set up for blocked words, I'm going to remove them all because I'm not sure about the terms that are not allowed on facepunch.
[code]Matsu.BlockedWords = {
"test",
}[/code]
How would I make it so if they type tes or anything close to what the banned word is, it gets blocked. Is there an easy way? Here's the ban function.
[code]local function blockCmds( ply, text, public )
if Matsu.Config.EnableBlockedWords then
for _, v in pairs(Matsu.BlockedWords) do
if string.find(text, v) then
return ""
end
end
end
end
hook.Add( "PlayerSay", "blockCmds", blockCmds)[/code]
Well, you need to first specify how close you want the text to be to the banned word... if you want it to be anything close to 'test', then simply typing 't' would get you banned. Maybe think of a limit first
You'll probably just want to use lua patterns. [url]https://www.lua.org/pil/20.2.html[/url]
Alternatively, you could do a table of regular expression strings which would allow a bit more customizing based on each word.
Otherwise we need some more details on how refined it should be like MPan said.
Some kind of ruleset. How many characters can be removed from the string and still be blocked ("tst", "tet", "tt", "t", etc - what is OK)? Should it block all forms of that word even if characters are added or is "testicles" okay? Things like that.
[QUOTE=jackool;50356314]Alternatively, you could do a table of regular expression strings which would allow a bit more customizing based on each word.
Otherwise we need some more details on how refined it should be like MPan said.
Some kind of ruleset. How many characters can be removed from the string and still be blocked ("tst", "tet", "tt", "t", etc - what is OK)? Should it block all forms of that word even if characters are added or is "testicles" okay? Things like that.[/QUOTE]
I'll probably just use a table.
Sorry, you need to Log In to post a reply to this thread.