02-20-2021, 02:52 AM
(This post was last modified: 02-21-2021, 06:24 PM by RussEfarmer. Edited 4 times in total.)
Here's a simple script that prevents a message containing anything in that table from getting sent. Drop it in lua/autorun and you're off to the races. If we get the timed mutes/gags addon I wrote installed, it would be very easy to have this automatically mute the player for a few minutes if they send a message that gets blocked, if we wanted to.
https://github.com/RussEfarmer/bad-word-slur-blocker
https://github.com/RussEfarmer/bad-word-...e/automute
https://github.com/RussEfarmer/bad-word-slur-blocker
https://github.com/RussEfarmer/bad-word-...e/automute
Code:
badwords = {
"badword1",
"badword2",
"badword3",
"badword4",
"badword5" -- don't put a comma on the last one
}
function findBadWords(table, text)
for k,v in pairs(table) do
if string.find(text, v) then return true end
end
end
if SERVER then
hook.Remove("PlayerSay", "nobadword")
hook.Add( "PlayerSay", "nobadword", function(ply, text)
if findBadWords(badwords, text) then return "" end
end)
end