So I've been writing a simple word/slur filter for a plugin I'm making with just custom lua I write as a collection of that sort of thing. And when I got to writing the word/slur/chat filter I found a weird bug.
It seems to only want to filter a set amount. For example if I have it filter out the word "cheese" then if I type cheese once it'll filter it out fine, if I do it again it'll work but if I type cheese 3 or more times it won't grab all of them, only the first two instances, it's weird.
Here's the logic behind it.
local message = string.Split(text, " ") --Text comes from a PlayerSay hook
for _, word in pairs(message) do
local prev_word = word
word = string.gsub(word, "[%p]", "")
if badWords[string.lower(word)] then
table.insert(message, getIndex(message, prev_word), cleanWords[math.random(#cleanWords)])
table.remove(message, getIndex(message, prev_word))
end
end
Thinking I was missing something that a second pair of eyes could point me towards, if you need more just let me know.
Thanks