• Steam ID whitelist connect
    12 replies, posted
Is there a script for a Steam ID whitelist to connect to a server? Can't seem to find anything like this anywhere and help would be very appreciated.
Try that [lua] local SteamIDS = { "Steam ID1", "Steam ID2", "Steam ID3" } local function CheckSID(ply, sid) if (table.HasValue(SteamIDS, sid)) then ply:Kick("You're SteamID is on the list of EVIL!") end end hook.Add("PlayerAuthed", "CheckSID", CheckSID) [/lua] Put it in lua/autorun/server/RandomFilename.lua
That's a blacklist script, isn't it? Just needs a not on line 8.
[QUOTE=MegaJohnny;21211910]That's a blacklist script, isn't it? Just needs a not on line 8.[/QUOTE] Oh, I misread it :P but yeah, a simple not or ! should work Info to OP: This script allowes users on the list to get in, and all others get kicked. The other works the other way around ( Kicks all on the list and allows all other users in) [lua] local SteamIDS = { "Steam ID1", "Steam ID2", "Steam ID3" } local function CheckSID(ply, sid) if (!table.HasValue(SteamIDS, sid)) then ply:Kick("You're SteamID is on the list of EVIL!") end end hook.Add("PlayerAuthed", "CheckSID", CheckSID) [/lua]
[QUOTE=Trivkz;21212410]Oh, I misread it :P but yeah, a simple not or ! should work Info to OP: This script allowes users on the list to get in, and all others get kicked. The other works the other way around ( Kicks all on the list and allows all other users in) local SteamIDS = { "Steam ID1", "Steam ID2", "Steam ID3" } local function CheckSID(ply, sid) if (!table.HasValue(SteamIDS, sid)) then ply:Kick("You're SteamID is on the list of EVIL!") end end hook.Add("PlayerAuthed", "CheckSID", CheckSID) [/QUOTE] Awesome, but is it possible to add IDs through the console?
[lua]local SteamIDS = { "Steam ID1", "Steam ID2", "Steam ID3" } local function CheckSID(ply, sid) if (!table.HasValue(SteamIDS, sid)) then ply:Kick("You're SteamID is on the list of EVIL!") end end hook.Add("PlayerAuthed", "CheckSID", CheckSID) local function AddSteamIDs(ply, cmd, args) if ply:IsSuperAdmin() then table.insert(SteamIDS, args[1]) end end concommand.Add("SteamID_add", AddSteamIDs)[/lua] Give that a go. Its been ages since I have coded lua, so it may error. In the console, type "SteamID_add STEAMIDHERE " (Without the quotes)
[QUOTE=Jamie932;21213220][lua]local SteamIDS = { "Steam ID1", "Steam ID2", "Steam ID3" } local function CheckSID(ply, sid) if (!table.HasValue(SteamIDS, sid)) then ply:Kick("You're SteamID is on the list of EVIL!") end end hook.Add("PlayerAuthed", "CheckSID", CheckSID) local function AddSteamIDs(ply, cmd, args) if ply:IsSuperAdmin() then table.insert(SteamIDS, args[1]) end end concommand.Add("SteamID_add", AddSteamIDs)[/lua] Give that a go. Its been ages since I have coded lua, so it may error. In the console, type "SteamID_add STEAMIDHERE " (Without the quotes)[/QUOTE] Looks like it would work, however you need to put quotes around the steamid since : seperates arguments: SteamD_add "STEAM_0:1:12341234"
[QUOTE=Jamie932;21213220]local SteamIDS = { "Steam ID1", "Steam ID2", "Steam ID3" } local function CheckSID(ply, sid) if (!table.HasValue(SteamIDS, sid)) then ply:Kick("You're SteamID is on the list of EVIL!") end end hook.Add("PlayerAuthed", "CheckSID", CheckSID) local function AddSteamIDs(ply, cmd, args) if ply:IsSuperAdmin() then table.insert(SteamIDS, args[1]) end end concommand.Add("SteamID_add", AddSteamIDs) Give that a go. Its been ages since I have coded lua, so it may error. In the console, type "SteamID_add STEAMIDHERE " (Without the quotes)[/QUOTE] [B][URL="http://wiki.garrysmod.com/?title=Glon.encode"]Glon.encode [IMG]http://wiki.garrysmod.com/favicon.ico[/IMG][/URL][/B] [B][URL="http://wiki.garrysmod.com/?title=Glon.decode"]Glon.decode [IMG]http://wiki.garrysmod.com/favicon.ico[/IMG][/URL][/B] Its better to save it to a txt file using glone couse if the server crashes or restarts all added steamid's via SteamID_add will be gone.
[QUOTE=yuriman;21213794][B][URL="http://wiki.garrysmod.com/?title=Glon.encode"]Glon.encode [IMG]http://wiki.garrysmod.com/favicon.ico[/IMG][/URL][/B] [B][URL="http://wiki.garrysmod.com/?title=Glon.decode"]Glon.decode [IMG]http://wiki.garrysmod.com/favicon.ico[/IMG][/URL][/B] Its better to save it to a txt file using glone couse if the server crashes or restarts all added steamid's via SteamID_add will be gone.[/QUOTE] Yeah, I realised that. I just couldn't really be bothered. Thanks for the heads up, yakahughes.
Thanks for all he help, it works perfect. I don't want to push it, but is it possible with those IDs that I could set a name to each one so when someone on the whitelist joins it will say "[Steam ID] [Name] allowed." or something like that.
As in a name associated with each Steam ID or just the Steam community name thing of the player joining? If you mean the former: [lua] local SteamIDS = { ["Steam ID1"] = "Name 1", ["Steam ID2"] = "Name 2", ["Steam ID3"] = "Name 3" } local function CheckSID(ply, sid) if (SteamIDS[sid]) then PrintMessage(HUD_PRINTTALK, sid.." ("..SteamIDS[sid]..") joined") else ply:Kick("Your Steam ID is not on the whitelist") end end hook.Add("PlayerAuthed", "CheckSID", CheckSID) local function AddSteamIDs(ply, cmd, args) if ply:IsSuperAdmin() then SteamIDS[args[1]] = args[2] end end [/lua] The command now has a second argument for the name. Not tested, so post any errors.
[QUOTE=MegaJohnny;21215606]As in a name associated with each Steam ID or just the Steam community name thing of the player joining? If you mean the former: local SteamIDS = { ["Steam ID1"] = "Name 1", ["Steam ID2"] = "Name 2", ["Steam ID3"] = "Name 3" } local function CheckSID(ply, sid) if (SteamIDS[sid]) then PrintMessage(HUD_PRINTTALK, sid.." ("..SteamIDS[sid]..") joined") else ply:Kick("Your Steam ID is not on the whitelist") end end hook.Add("PlayerAuthed", "CheckSID", CheckSID) local function AddSteamIDs(ply, cmd, args) if ply:IsSuperAdmin() then SteamIDS[args[1]] = args[2] end end The command now has a second argument for the name. Not tested, so post any errors.[/QUOTE] Works great, thank you.
[QUOTE=Kronix904;21218301]Works great, thank you.[/QUOTE] Someone above mensioned saving. I suggest you add it in.
Sorry, you need to Log In to post a reply to this thread.