This will greatly reduce my bans. So I can stop people from posting links, I added "www.", "http", etc. Problem is that I need mods and admins to be able to post the steam link for our group page. Even I can't do it as owner. Is there a way to disable the censor for mods. admins?
do you want mods to bypass all censors, or just be able to post web links?
Ok, Ven. I made some modifications using only the code you had there, nothing of my own. I'll walk you through what I did. "function GetOuttaHere" is really un-needed. You can set up what you want to do when the person is decidedly kicked in the same function that checks for the words, so I got rid of that function. Using "return" ends the fuction with the specified results. So, in a script like this, order is everything. It starts off like it did before, except all the local variables except one was removed. You only need to predefine a variable if there's a chance it is called before it's set, which isn't what's happening here. So on line 20, replace is defined as a local variable. Otherwise the censoring code was solid.
After filter has been set as a censored word, we can move on with how to handle censoring and kicking. First it checks if you're an admin or sadmin, and if you're able to be kicked. If you can't be kicked, it then checks if you're censored. If not it returns the text (which finishes the function), else it returns the filter. If you can be kicked, it skips the admin only filter, and treats you like a regular user. Next is where it kicks you, if kick is enabled, you're kicked; all one line. Finally, it checks if the censor is turned on, and if it is it returns the filer, else it returns the real text.
The most important thing to do is make sure what order to check things, and to try and be as little complicated as possible. I try to tie as many things into a single if statement that can be checked together. Here's my edited code below. Tell me if you need to explain anything else I did. I did test this as a user, admin, and superadmin, and it works fine for me.
CenKik = CenKik or {}
CenKik.words = {
"lolipop",
"damndude",
"corecheng",
"prinnies" --Always leave the last one without a comma.
}
CenKik.kik = false --Enable kicking?
CenKik.kikadmin = false --Kick Admins?
CenKik.kiksadmin = false --Kick SuperAdmins?
CenKik.censor = true --Enable censoring?
CenKik.cenadmin = true --Censor Admins? (Neku: Bad idea to not censor.)
CenKik.censadmin = false --Censor SuperAdmins? (Neku: Still a bad idea to not censor.)
local function Riplash( ply, text )
local filter = text
for k,v in pairs(CenKik.words) do
if string.find( string.lower(filter), v, 1, true ) then
if CenKik.censor then
local replace = string.rep( "*", string.len( v ) )
filter = string.gsub( string.lower(filter), v, replace )
end
end
end
if (ply:IsAdmin() and not CenKik.kikadmin) or (ply:IsSuperAdmin() and not CenKik.kiksadmin) then
if (ply:IsAdmin() and not CenKik.cenadmin) or (ply:IsSuperAdmin() and not CenKik.censadmin) then
return text
else
return filter
end
end
if CenKik.kik then RunConsoleCommand("ulx", "kick", meanie:Nick(), "Attempting to use a blocked word.") end
if CenKik.censor then
return filter
else
return text
end
end
hook.Add( "PlayerSay", "CenKik", Riplash )