Clan tag kicker?

Hello, I am in need of a script that detects certain clan tags (I’ll edit these in) and kicks the user if their name contains it. I’d do this myself but I haven’t got the faintest clue on how to check someone’s nickname…

tia

[lua]
function Autokick(ply)
if string.find(ply:Nick(), “[Minge]”) == 1 then
ply:Kick(“OMG YOU EZ TEH MINGE”)
end
end
hook.Add(“PlayerInitialSpawn”, “TagKick”, Autokick)
[/lua]

Checks if [Minge] is the first 8 characters in someone’s name.

thanks :smile: i’ll see if this works.

Doesn’t check if it’s the first 8 characters. Looks for them…

Also [Minge] is 7 characters.

Also no need for == 1.

   if string.find(ply:Nick(), "[Minge]") then

rather

that script kicks everyone who joins my server… :tinfoil:

[editline]31st January 2011[/editline]

johnnythunders made a great working script for me. thanks for your help :v:

[lua]local tags = {"%[DICK%]" , “%[TWAT%]”}

hook.Add(“PlayerInitialSpawn” , 0 , function(pl)
local nick = pl:Nick()

for k , v in pairs(tags) do
	if string.match(nick , v) then	
		pl:Kick("FUck off")
	end
end

end )[/lua]

Bit better I think.

Is == <value> also used in LUA?
I know it’s used in E2. And, I don’t know any lua, so don’t freak out :frog:

if Test

is the same as

if Test == 1

Could also mean “if test exists? then”

[lua]local test = true

print(test ~= nil)
print(test == 1)[/lua]

Now is ~= nil equivalent to == 1?

More like
[lua]
if a != nil and a !=0
[/lua]
If Test will return false atm the variable not exists - if Test == 1 would error because it tries to compare a nil value to a number
If Test will return true atm the variable is equal to 2 - if Test == 1 would return false

Also there is no reason why Amokov’s his code would be incorrect. as clan-tags are mainly used at the start of the name the checking for == 1 makes sense.

Yeah, but why check for it only in the beginning? His way is more correct.