Kick people with LUA?

I hope I’m in the correct section.

I want to make a LUA script that will kick everyone who doesn’t have their Steam ID in a list I manually edit. How do I do this?

I would write out the whole script but I’m a tad busy, but here’s some links which could help you get started. - Store steam ids in a table - Loop to read through the table - If the steamid is not in the table, return with the kick

An example. Untested

local allowedsteamids = {
     ["STEAMIDHERE"] = true,

hook.Add("PlayerInitialSpawn", "whyareyoudoingthis?", function(ply)
  if  allowedsteamids[ply:SteamID()] then return end
       ply:Kick("Wrong SteamID")

ok first from the wiki:

-Snip (Just realized what I did wrong, sorry)

STool isn’t wrong. STool = Scripted Tool. IIRC

Sorry… just used the image for reference. STool is fine

You could always make a server with a password.

Use the CheckPassword hook, check if the SteamID is in a table, and if not, return false and an error message.

Sounds like you want a whitelist addon.

They would then have to join the server and download everything just to be kicked when they spawn. Use CheckPassword instead.

All of these check for the SteamID way too late…

Use the CheckPassword hook or player_connect game-event. It’ll check immediately upon connect…

local SteamIDWhitelist = {
     ["STEAM_0:1:4173055"] = true; -- Acecool


hook.Add( "CheckPassword", "Acecool:Whitelist", function( _steam64, _ip, _svpass, _clpass, _name ) 
	if ( !SteamIDWhitelist[ util.SteamIDFrom64( _steam64 ) ] ) then
		RunConsoleCommand( "kickid", _steam64, "You're not whitelisted!" );
end );

VS: //

local SteamIDWhitelist = {
     ["STEAM_0:1:4173055"] = true; -- Acecool


they join the server.

gameevent.Listen( "player_connect" );
hook.Add( "player_connect", "player_connect:TrackingPlayers", function( _data )
	-- local _name =;			// Same as Player:Nick( );
	local _steamid = _data.networkid;	// Same as Player:SteamID( );
	-- local _ip = _data.address;			// Same as Player:IPAddress( );
	local _id = _data.userid;			// Same as Player:UniqueID( );
	-- local _bot =;				// Same as Player:IsBot( );
	-- local _index = _data.index;			// Same as Player:EntIndex( );
	-- local _p = Player( _id ); 			// The Player Entity, if valid

	// Player has connected; this happens instantly after they join -- do something..
	// Add to spawning list or players list with isspawning flag - I recommend using one list with status flags.

	if ( !SteamIDWhitelist[ _steamid ] ) then
		RunConsoleCommand( "kickid", _id, "You're not Whitelisted!" );
end );

The kickid may be incorrect… You may need to use Steam, can’t recall. Two different ways; the player_connect I commented out the additional data and derivative data which wasn’t used…

By waiting until the PlayerInitialSpawn, that is when the player is sending client info; if they’re not allowed in why allow them to wait and download everything? Kind of mean…