I've started a small private server for a group at my college. We've decided to all pay a couple of dollars a month to cover the hosting costs, and to have a whitelist system for people who have paid. But I'm not quite sure how to make a whitelist system (where everyone is banned except people listed) instead of a blacklist (where only people listed are banned). How would I go about making one? We are using ULX, if its any help. Thanks.
With ULX there's a way you can set people as immune/unbannable, try looking at the docs (it will probably also give them some wort of adminship, which might be an issue).
[QUOTE=Xaja;20710428]I've started a small private server for a group at my college. We've decided to all pay a couple of dollars a month to cover the hosting costs, and to have a whitelist system for people who have paid. But I'm not quite sure how to make a whitelist system (where everyone is banned except people listed) instead of a blacklist (where only people listed are banned). How would I go about making one? We are using ULX, if its any help. Thanks.[/QUOTE]
So you want people to not be able to join if they haven't payed?
sv_password
[QUOTE=Xaja;20710428]I've started a small private server for a group at my college. We've decided to all pay a couple of dollars a month to cover the hosting costs, and to have a whitelist system for people who have paid. But I'm not quite sure how to make a whitelist system (where everyone is banned except people listed) instead of a blacklist (where only people listed are banned). How would I go about making one? We are using ULX, if its any help. Thanks.[/QUOTE]
Seems easy it will require gatekeeper so you can have your own custom message instead of kicked by console.
I'm hoping that instead of using a password, I can use a whitelist. Everyone who's SteamID (or something like that) isn't in a list somewhere is automatically kicked from the server (or something like that). The problem with using just an sv_password is that it would be easy for someone who has paid to tell people who haven't paid the password. Using a whitelist is 'foolproof' in that only accounts that have been paid for can join the server. What's all this about gatekeepers?
A binary dll that would allow you to write your whitelist in lua
[url]http://www.facepunch.com/showthread.php?t=695636[/url]
That dll looks really good. Sadly I only know the very basics of Lua, and nothing about how it works with Gmod. Would anyone have any tips on how to start this whitelist system? Or does anyone know of an already made alternative?
You don't need it to setup a basic whitelist. If I was gonna code this, I would it loop through a table of allowed steamIDs when a client joins and kicks them if their steam ID doesn't match one, it would be a very easy script to write.
[QUOTE=Kybalt;20728968]You don't need it to setup a basic whitelist. If I was gonna code this, I would it loop through a table of allowed steamIDs when a client joins and kicks them if their steam ID doesn't match one, it would be a very easy script to write.[/QUOTE]
Yeah then [lua]table.insert()[/lua] to insert the steamID instead of adding to the file and changing map.
Okay so,
I'm looking at a few different functions. One that runs every time someone attempts to connect, and checks their SteamID against a list. Then other for manipulating the list. So something like (Pseudo C++ code):
[code]
int Gatekeeper ()
{
for(i=0;i<members.length();i++)
{
if (ConnectingID() == member[i]) {return 0}
i++
}
Connecting().Kick()
return 1
}
if (Connecting()) {Gatekeeper()}
[/code]
Is this the sort of thing that would work? I'm not really a coder, so wouldn't know how to go any further than this.
And then another 3 commands, one to add an ID to the list, another to delete it and a final one to return all members of the list. Would these be console (~, that sort of console) commands only available to the superadmin?
I don't know anything about Gmod addons (or Lua). Is there anyone that could make this into a proper script (Kybalt maybe)? If you do I'll be forever indebted to you :-)
[lua]require("gatekeeper")
local function Checkuser(name, pass, steam, ip)
if steam ~= "STEAM_0:1:16258120" or steam ~= "STEAM_0:0:9249431" then
return {false, "Sorry u need to donate."}
end
return
end
hook.Add("PlayerPasswordAuth", "Checkuser", Checkuser)
[/lua]
[lua]require("gatekeeper")
local AllowedSteamIDs = {
"STEAM_0:0:00000000",
"STEAM_0:0:00000001"
} --Seperate all values that are not the last with a comma, like above.
local function Check( name, pass, sid, ip )
if not table.HasValue( AllowedSteamIDs, sid ) then
return { false, "Sorry " .. name .. ", you need to donate." }
end
return
end
hook.Add( "PlayerPasswordAuth", "Check", Check )[/lua]
Same as above, but using a table to check.
Put it in a file in lua/autorun/server, and it will work automatically.
[editline]A reason![/editline]
Oh, and Cubar, since their steamid will never be two things at once, you should use an "and" check, and not a "or" check.
Yay! Thank you very much :-)
Is there any (easy) way to make a console command or something like it that would allow me to add and maybe delete IDs to/from the table without having to edit the file and change maps?
[QUOTE=Whitewater;20732890]
Oh, and Cubar, since their steamid will never be two things at once, you should use an "and" check, and not a "or" check.[/QUOTE]
That's is what i was thinking so i did the or instead.
[QUOTE=Xaja;20734256]Yay! Thank you very much :-)
Is there any (easy) way to make a console command or something like it that would allow me to add and maybe delete IDs to/from the table without having to edit the file and change maps?[/QUOTE]
[lua]
table.insert() Add em
table.Remove() Remove em
[/lua]
Oh no! I've added Whitewater's script to a file called 'gatekeeper.lua' in lua/autorun/server, not edited at all, but I can still connect just fine. Does anyone know why? I also tried naming it different things (just incase) and changed the "Sorry " .. name .. ", you need to donate." to "Sorry you need to donate" just incase the unquoted .. name .. was screwing things up.
Anyone?
[QUOTE=Xaja;20878934]Anyone?[/QUOTE]
Edit the following file server-side:
gamemodes\sandbox\gamemode\init.lua
Line 189, change
[LUA]
function GM:PlayerInitialSpawn( ply )
self.BaseClass:PlayerInitialSpawn( ply )
PlayerDataUpdate( ply )
end
[/LUA]
to
[LUA]
function GM:PlayerInitialSpawn( ply )
self.BaseClass:PlayerInitialSpawn( ply )
if !ply:SteamID() == STEAM_0:1:16258120 or !ply:SteamID() == STEAM_0:1:16258120 then ply:Kick("Sorry, only donators are allowed.") end
PlayerDataUpdate( ply )
end
[/LUA]
I make no promises it will work, but it should. Also I might have gotten it wrong and it might be ply:SteamID(STEAM_0:0:0000000), I haven't exactly tested this.
[QUOTE=darksoul69;20879608]Edit the following file server-side:
gamemodes\sandbox\gamemode\init.lua
Line 189, change
[LUA]
function GM:PlayerInitialSpawn( ply )
self.BaseClass:PlayerInitialSpawn( ply )
PlayerDataUpdate( ply )
end
[/LUA]
to
[LUA]
function GM:PlayerInitialSpawn( ply )
self.BaseClass:PlayerInitialSpawn( ply )
if !ply:SteamID() == STEAM_0:1:16258120 or !ply:SteamID() == STEAM_0:1:16258120 then ply:Kick("Sorry, only donators are allowed.") end
PlayerDataUpdate( ply )
end
[/LUA]
I make no promises it will work, but it should. Also I might have gotten it wrong and it might be ply:SteamID(STEAM_0:0:0000000), I haven't exactly tested this.[/QUOTE]
Hello, we allready done it, now we are going to table.insert and table.remove to add and remove them hence table. :wink:
Just a bumb. The script still isn't working. I filed a support ticket with my server host, and the person said that he would expect a function call, not just return values.
Would anyone else like to have a shot at writing it?
[QUOTE=Xaja;21008928]Just a bumb. The script still isn't working. I filed a support ticket with my server host, and the person said that he would expect a function call, not just return values.
Would anyone else like to have a shot at writing it?[/QUOTE]
Do you have gatekeeper.
Oh god, I can't believe I've been so stupid D: The "require("gatekeeper")" should really have given it away. Sorry about that.
But, I'm hosted with Xenon Servers, and they don't seem to allow binary modules to be uploaded to the server (fair enough I guess). Is there any way to rewrite the script to not need Gatekeeper?
[QUOTE=Xaja;21025983]Oh god, I can't believe I've been so stupid D: The "require("gatekeeper")" should really have given it away. Sorry about that.
But, I'm hosted with Xenon Servers, and they don't seem to allow binary modules to be uploaded to the server (fair enough I guess). Is there any way to rewrite the script to not need Gatekeeper?[/QUOTE]
[IMG]http://i42.tinypic.com/2vdibdz.png[/IMG]
Ha! Thank you :D Don't know why I didn't check that. Thanks for all the help everyone.
Sorry, you need to Log In to post a reply to this thread.