--[[
	-	Version 0.1:
	Thanks to the help of MrPresident on the UlyssesMod.net forums, this is working. Or should be working.
	-	Version 0.2:
	Added ULib's NameChange hook, so if someone changes their name to something that contains one of the words inside "kickstrings", they will get kicked.
	-	Version 0.3:
	Added print-to-chat for admins if someone gets kicked.
	
	Other notes:
	Please keep in mind that if you add a word like "ass", people with names like "mass" will get kicked.
	
	
]]
local kickstrings = { 
"fuck", "cunt", "faggot", "asshole", "nigger", "nigga", "dildo", "orgasm", 
"masturbate", "penis", "vagina", "shit", "blowjob", "ejaculate", "testicle",
"wanker", "queef", "damn",
} --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 to something more family friendly." )
						for _, a in pairs( player.GetAll() ) do
							if a:query( "ulx seeasay" ) then
								ULib.tsay( a, "Autokicked player: " .. ply:Nick() .. " (" .. ply:SteamID() .. ") for having the string (" .. v .. ") in their name." )
							end
						end
						return
				elseif string.find( pname, " ") then
						ULib.kick(ply, "Auto-kicked for having a blank character in your name. ALT + 32 doesn't work here, buddy.")
						for _, a in pairs( player.GetAll() ) do
							if a:query( "ulx seeasay" ) then
								ULib.tsay( a, "Autokicked player: " .. ply:Nick() .. " (" .. ply:SteamID() .. ") for having a blank character in their name (ALT + 32)." )
							end
						end
						return
                end
       
        end
       
end
hook.Add( "PlayerInitialSpawn", "NameKicker", NameKicker )

function NameKickOnChange (ply, old, new)

		for k, v in pairs( kickstrings ) do
		
			if string.find ( string.lower(new), v ) then
						
						ULib.kick( ply, "You changed your name to include the word '" .. v .. "' in your name. Please change your name to something more family friendly." )
						for _, a in pairs( player.GetAll() ) do
							if a:query( "ulx seeasay" ) then
								ULib.tsay( a, "Autokicked player: " .. ply:Nick() .. " (" .. ply:SteamID() .. ") for having the string (" .. v .. ") in their name." )
							end
						end
						return
			end
		end
end
hook.Add( "ULibPlayerNameChanged", "NameKickOnChange", NameKickOnChange )