General > Developers Corner

Name Checker/Kick

(1/6) > >>

Decicus:
Hello everyone.
I'm developing a script that is sort of advanced, and I have a base idea of it. I need some help with something, and it would be great if you could point me in the right direction.
I'm part of a family friendly server environment, where we don't allow swearing/cursing, this includes bad words in names. What I'm trying to do is to create a script to check the name and find words from a list, and if it find a word from that list in your name, you'll get kicked.

It seems to be quite hard, if not impossible to even pull off. I've been thinking about using string.sub together with the PlayerInitialSpawn hook, but other than that I'm pretty ignorant of what else I need to do to pull this off (if it's even possible).

Any help is appreciated. I'm still pretty newbie in Lua, but I'm starting to understand more and more of it. So if I don't get what you mean the first time, please be patient.

Thanks in advance!
~Decicus/Alex

MrPresident:
I hope you don't mind I just did this for you. :D

I am sitting on 24 hour CQ and am terribly bored. Not to mention this is a very simple script.

http://pastebin.com/wykH1YHB

Granted.. this isn't tested but it should work. Just replace and add the strings in the table at the top with the strings you wish to kick for. Make sure you take into account possible workarounds. For example (while remaining family-friendly myself):
ask and @$k and @sk and a$k are all different strings and would each need to be added to the table.

Also be careful because you could be unintentionally kicking for legitimate strings. Someone with the name assignment would be kicked for having the word (insert first three letters of that word here) as a part of their name.

Trying to write a script that would detect strings while also finding legitimate uses of those strings would indeed be a fairly difficult task. Choose your strings carefully.

There are some strings that would never be legitimate. For example the F word, the C word, the S word. You get my gist.


--- Code: ---local kickstrings = { "test", "these", "strings" } --Make sure these are ALL lowercase

function NameKicker( ply )

local pname = string.lower( ply:Nick() )

for k, v in pairs( kickstrings ) do

if string.find( pname, v ) then

ULib.kick( ply, "Auto-Kicked for having the string " .. v .. " in your name. Please change your name and rejoin" )

end

end

end
hook.Add( "PlayerInitialSpawn", "NameKicker", NameKicker )

--- End code ---

Decicus:
I have fallen in love with you, MrPresident. Thanks a lot!

And yes, I actually kept in mind that some words include other words. So I was only going to use the strongest words that you basically said yourself.
Thank you, MrP. I appreciate this greatly!

MrPresident:
Place a return after the kick line.


Otherwise, the loop might continue after it kicks a player and cause an error.


--- Code: ---local kickstrings = { "test", "these", "strings" } --Make sure these are ALL lowercase

function NameKicker( ply )

local pname = string.lower( ply:Nick() )

for k, v in pairs( kickstrings ) do

if string.find( pname, v ) then

ULib.kick( ply, "Auto-Kicked for having the string " .. v .. " in your name. Please change your name and rejoin" )
return

end

end

end
hook.Add( "PlayerInitialSpawn", "NameKicker", NameKicker )

--- End code ---

Decicus:
Thanks. I did that.
How would I do it basically print a message for the admins? I'm not sure how I'm gonna add IsAdmin()/IsSuperAdmin() into that.

Navigation

[0] Message Index

[#] Next page

Go to full version