General > Developers Corner

Whitelist

(1/1)

Tophat Man:
How would I make a whitelist? Basically the opposite of a ban list, only lets certain people in and kicks others. I know that I would need a table and a function that checks on spawn if that player is on the table but I don't really know how to write anything on my own with lua. This is for our G4P space build server which we want to be members only basically but also people we invite and such. thanks.

jay209015:
Here's my attempt:


--- Code: ---local whitelist = { "SteamID1", "SteamID2" } // add your steam id's here

function CheckWhiteList( ply )
ply.kick = false
for k, v in pairs( whitelist ) do
if ply:SteamID == v then
local ply.kick = false
return
else
local ply.kick = true
end
end
if ply.kick then
ULib.kick( ply )
end
end
hook.Add( "PlayerInitialSpawn", "WhitelistCheck", CheckWhiteList )
--- End code ---

Not tested.

An Error Has Occurred!

array_keys(): Argument #1 ($array) must be of type array, null given

[0] Board index

Go to full version