• Print

Author Topic: Whitelist  (Read 12448 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

Offline Megiddo

  • Ulysses Team Member
  • Hero Member
  • *****
  • Posts: 6214
  • Karma: 394
  • Project Lead
Re: Whitelist
« Reply #2 on: June 26, 2008, 04:58:49 am »
Code: Lua
  1. local whitelist = { "SteamID1", "SteamID2" } -- add your steam id's here
  2.  
  3. function CheckWhiteList( ply )
  4.         if not ULib.findInTable( whitelist, ply ) then
  5.                 ULib.kick( ply )
  6.         end
  7. end
  8. hook.Add( "PlayerInitialSpawn", "WhitelistCheck", CheckWhiteList )
Partially stolen from Jay but I improved a bit. ;)
I didn't test it either.
Experiencing God's grace one day at a time.

Offline JamminR

  • Ulysses Team Member
  • Hero Member
  • *****
  • Posts: 8096
  • Karma: 390
  • Sertafide Ulysses Jenius
    • Team Ulysses [ULib/ULX, other fine releases]
Re: Whitelist
« Reply #3 on: June 26, 2008, 02:53:32 pm »
I'd hate to join a server, download any lua it had, take the long process Gmod does to load any map whether I have it or not, to be kicked once I finally got everything.
Wouldn't a section on the G4P forums only for members who have access to the server, with a password in a sticky, be much better than the above?
At the least, to help prevent password sharing, include both.
Password the server.
Then and only then use whitelist.

"Though a program be but three lines long, someday it will have to be maintained." -- The Tao of Programming

Offline jay209015

  • Ulysses Team Member
  • Hero Member
  • *****
  • Posts: 934
  • Karma: 62
    • Dev-Solutions
Re: Whitelist
« Reply #4 on: June 26, 2008, 06:12:45 pm »
Quote
I'd hate to join a server, download any lua it had, take the long process Gmod does to load any map whether I have it or not, to be kicked once I finally got everything.
Wouldn't a section on the G4P forums only for members who have access to the server, with a password in a sticky, be much better than the above?
At the least, to help prevent password sharing, include both.
Password the server.
Then and only then use whitelist.

Agreed  ;D
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

  • Print