General > Developers Corner
Kick when X is said in chat
Eccid:
I'm awake, so here's what I made for you. If you only want kicking to happen, either leave the Banwords table empty, or delete between where it says ban begin and ban end.
Put this in lua\autorun\server\
--- Code: ---KickWords = KickWords or {}
BanWords = BanWords or {}
KickWords = { --Add what words to be kickable.
"poohead", --Any added word should be in this format,
"muggle" --last word does NOT have a comma after it.
}
BanWords = { --Same rules as above, only for banning
"poopypants",
"nerfherder"
}
hook.Add( "PlayerSay", "Kick For Words", function(ply, text)
--Kick Begin--
for a,b in pairs(KickWords) do
if string.find(string.lower(text), b, 1, true) then --Is a word being used?
RunConsoleCommand("ulx", "kick", ply:Nick(), "Using a banned word.") --If yes, kick them
ulx.fancyLogAdmin( ply, true, "#A was kicked for saying the following: #s", text) --Tell admins they were kicked and what they said.
return "" --Return nothing so everyone can't read what was said.
end
end
--Kick End--
--Ban Begin--
for a,b in pairs(BanWords) do --Same as above, except for banning.
if string.find(string.lower(text), b, 1, true) then
RunConsoleCommand("ulx", "ban", ply:Nick(), "0", "Using a banned word.") --Ban time is set to 0 for perm, feel free to edit.
ulx.fancyLogAdmin( ply, true, "#A was banned for saying the following: #s", text)
return ""
end
end
--Ban End--
end )
--- End code ---
Make sure your admins know what words are in the list and adhere to the rules. It looks bad if your admins are getting kicked for things like this.
Neku:
--- Quote from: Eccid on January 09, 2014, 12:18:51 AM ---I'm awake, so here's what I made for you. If you only want kicking to happen, either leave the Banwords table empty, or delete between where it says ban begin and ban end.
Put this in lua\autorun\server\
--- Code: ---KickWords = KickWords or {}
BanWords = BanWords or {}
KickWords = { --Add what words to be kickable.
"poohead", --Any added word should be in this format,
"muggle" --last word does NOT have a comma after it.
}
BanWords = { --Same rules as above, only for banning
"poopypants",
"nerfherder"
}
hook.Add( "PlayerSay", "Kick For Words", function(ply, text)
--Kick Begin--
for a,b in pairs(KickWords) do
if string.find(text, b, 1, true) then --Is a word being used?
RunConsoleCommand("ulx", "kick", ply:Nick(), "Using a banned word.") --If yes, kick them
ulx.fancyLogAdmin( ply, true, "#A was kicked for saying the following: #s", text) --Tell admins they were kicked and what they said.
return "" --Return nothing so everyone can't read what was said.
end
end
--Kick End--
--Ban Begin--
for a,b in pairs(BanWords) do --Same as above, except for banning.
if string.find(text, b, 1, true) then
RunConsoleCommand("ulx", "ban", ply:Nick(), "0", "Using a banned word.") --Ban time is set to 0 for perm, feel free to edit.
ulx.fancyLogAdmin( ply, true, "#A was banned for saying the following: #s", text)
return ""
end
end
--Ban End--
end )
--- End code ---
Make sure your admins know what words are in the list and adhere to the rules. It looks bad if your admins are getting kicked for things like this.
--- End quote ---
Meh. I was gonna do it, but I ran into issues. (See my Lua n00b thread.)
Thanks for taking my place.
Eccid:
--- Quote from: Ven01273 on January 09, 2014, 12:26:38 AM ---Meh. I was gonna do it, but I ran into issues. (See my Lua n00b thread.)
Thanks for taking my place.
--- End quote ---
:P No problem. I was already awake and had something similar mostly written. Just took a few minutes to polish it.
frustratedgamers:
sweet! thank you very much :D
Storm:
Can you tell me if this would work in ttt?
Navigation
[0] Message Index
[#] Next page
[*] Previous page
Go to full version