I need help with this selective kick coding

On my TTT server we have a few people who can not get along with each other but are otherwise are fine players, in particular is a player(STEAM_0:1:5057813) who has been terrorizing a girl(STEAM_0:0:6037899) who also plays on the server (note that I have altered the ids).

 This code is designed to be placed in the autorun folder and scan every time someone joins first to see if she is on the server and, if so, to scan for him and kick him.  Unfortunately it does not work and does not return an error, can anyone point out what I'm doing wrong?


function CheckQ( ply )
 for _, v in pairs(player.GetAll()) do
  if v:SteamID() = STEAM_0:0:6037899 then
   for _, z in pairs(player.GetAll()) do
     if z:SteamID() = STEAM_0:1:5057813 then
      z:Kick("Oil and water, you two can't play together.")
     end
   end
  end
 end
end
hook.Add( "PlayerConnect", "playerconnect", CheckQ )


whats the error?

It doesn’t return an error.

-ninja’d-

Just ban one of them?

This is a horrible idea and it’ll be a real pain in the ass to implement more mismatches.

Just ban the douchebasket.

The ID should be a string and you are using = wrong.
Also, instead of doing the second check use the ply variable you get.

Thanks ms333! Can you extrapolate? To make it a string I put it in quotes, right? How should I be doing the =; and how do I use the ply variable?

This is what you’re looking for:
[lua]
local KickList = {
[“STEAM_0:1:5057813”] = true
}

hook.Add(“PlayerAuthed”, “PlayerAuthed”, function(ply, steamid, uniqueid)
local kickPly = KickList[steamid]
if !kickPly then return end
ply:Kick(“You are not allowed to join this Server.”)
end)
[/lua]

[lua]function CheckQ( ply )
if ply:SteamID() == “STEAM_0:0:6037899” then
for k, v in pairs(player.GetAll()) do
if v:SteamID() == “STEAM_0:1:5057813” then
v:Kick(“Oil and water, you two can’t play together.”)
end
end
end
end
hook.Add( “PlayerConnect”, “playerconnect”, CheckQ )[/lua]

edit: whoops, didn’t notice you were using = instead of ==. Fixed.

How does it check for the girls Id? The owner won’t let me ban him completely.

the ply argument is the player object of who’s connected (thanks to the PlayerConnect hook). In this case you check if that players SteamID is the girls (ply:SteamID()), if so: Loop through the players and check if the douchebasket is connected and kick.

[editline]12th July 2013[/editline]

Oh, you weren’t quoting me, haha. His code doesn’t do what you want as far as I can see. (you can make it do so with a few lines, though.)

Too bad that code is completely redundant in every way.

I simply fixed his code from the OP.

A better solution would be to post what you think would benefit him the most instead of using his code as a solution which wasn’t that great to begin with.

Thank you both, you both are very helpful and win all my internets. Don’t fight now.

To the OP I would suggest reading up on tables and how loops work.

You’re using = instead of ==

Doing an O( n^2 ) isn’t a good idea. You should probably do a check when they connect, then loop once and see if the other guy is in the server; if so deny the other.

Too slow

But feel free to post what would benefit me more brandonj4. I must learn all. Both what I’m doing wrong and what to do right.