ULX

Author Topic: Whitelist  (Read 8533 times)

0 Members and 1 Guest are viewing this topic.

Offline Tophat Man

  • Newbie
  • *
  • Posts: 17
  • Karma: 2
Whitelist
« on: June 25, 2008, 07:12:00 PM »
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.

Offline jay209015

  • Ulysses Team Member
  • Hero Member
  • *****
  • Posts: 934
  • Karma: 62
    • Dev-Solutions
Re: Whitelist
« Reply #1 on: June 25, 2008, 10:34:56 PM »
Here's my attempt:

Code: [Select]
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 )

Not tested.
An error only becomes a mistake when you refuse to correct it. --JFK

"And thus the downfall of the great ULX dynasty was wrought not by another dynasty, but the slow and steady deterioration of the leaders themselves, followed by the deprecation of the great knowledge they possessed." -Gmod, Chapter 28, verse 34 -- Stickly

An Error Has Occurred!

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