Steam Group auto ban?

Can someone help me create a script that will ban players on join if they are in a certain steam group?

[lua]
local Players = {}

local Group = “glua” // Name of the group ie http://steamcommunity.com/groups/glua
local num = 1

local function Success( str, len, head, http )
str = string.Replace(str, “</steamID64>”, “”)

    local tbl = string.Explode("&lt;steamID64&gt;", str)
   
    table.remove(tbl, 1)
   
    tbl[#tbl] = string.Replace(tbl[#tbl], "&lt;/members&gt;", "")
    tbl[#tbl] = string.Replace(tbl[#tbl], "&lt;/memberList&gt;", "")
   
    for k, v in pairs(tbl) do
            table.insert(Players, v)
    end

end

local function Success2( str, len, head, http )
local tbl = string.Explode("<memberCount>", str)

    table.remove(tbl, 1)
   
    tbl = string.Explode("&lt;/memberCount&gt;", tbl[2])
    num = string.Replace(tbl[1], "&lt;/memberCount&gt;", "")
    num = math.Clamp(math.Round(tonumber(num) / 1000), 1, 1000)
   
    compile()

end

function compile()
for i=1,num do
http.Fetch(“http://steamcommunity.com/groups/” … Group … “/memberslistxml/?xml=1&p=” … i, Success, nil)
end
end
http.Fetch(“http://steamcommunity.com/groups/” … Group … “/memberslistxml/?xml=1”, Success2, nil)

hook.Add(“CheckPassword”, “BadGroup”, function(sid, _, _, _, _)
return !table.HasValue(Players, sid)
end)
[/lua]

This should work but I haven’t touched gmod in months so maybe if it doesn’t someone will fix it.

I dont see where this is banning the player at or what it is returning if i need to add the code to make it ban the player. But anyways thank you <3

The main reason i need this is because this group http://steamcommunity.com/groups/Zuthar13# joined a server i manage and kinda went downhill from there.


hook.Add("CheckPassword", "BadGroup", function(sid,  _, _, _, _)
	return !table.HasValue(Players, sid)
end)

Basic refuses them connecting.

Banning all the people in the group, are going to create more problems;
A) What if the person had left the group? You need a list or something to unban them.
B) The server would need to ban 3570 people, every time you launch the server.

This simply prevents them from spawning in. I didn’t add any functions to ban because source bans are written to cfg and most people have a variety of admin mods which all use different functions ie ULib.ban or evolve:Ban.

[editline]3rd November 2015[/editline]

Getting to the point of 3570 people. This can actually deny a group of that size. If you watch this video I display a group over 10k users via derma. I wouldn’t want to ban a group of 3.k though that alot of people.

So now im having the issue of making it work on my server (im still a nub at lua) i dont know where to put it or to make the player dl it or what.

Create a lua file in lua/autorun/server and paste the code into that

So i put it in the lua/autorun/server file and its not stopping me from connecting to the server i have it loaded on.

Post the whole file in between: [code ]<the whole file.lua>[ /code] tags. We are not wizards so give us something to go after :stuck_out_tongue:


local Players = {}

--local Group = "http://steamcommunity.com/groups/Zuthar13#" // Name of the group ie http://steamcommunity.com/groups/glua
local Group = "Anti-Matter_Gaming" --my group to test it
local num = 1
 
local function Success( str, len, head, http )
        str = string.Replace(str, "</steamID64>", "")
       
        local tbl = string.Explode("<steamID64>", str)
       
        table.remove(tbl, 1)
       
        tbl[#tbl] = string.Replace(tbl[#tbl], "</members>", "")
        tbl[#tbl] = string.Replace(tbl[#tbl], "</memberList>", "")
       
        for k, v in pairs(tbl) do
                table.insert(Players, v)
        end
end
 
local function Success2( str, len, head, http )
        local tbl = string.Explode("<memberCount>", str)
       
        table.remove(tbl, 1)
       
        tbl = string.Explode("</memberCount>", tbl[2])
        num = string.Replace(tbl[1], "</memberCount>", "")
        num = math.Clamp(math.Round(tonumber(num) / 1000), 1, 1000)
       
        compile()
end
 
function compile()
        for i=1,num do
                http.Fetch("http://steamcommunity.com/groups/" .. Group .. "/memberslistxml/?xml=1&p=" .. i, Success, nil)
        end
end
http.Fetch("http://steamcommunity.com/groups/" .. Group .. "/memberslistxml/?xml=1", Success2, nil)

hook.Add("CheckPassword", "BadGroup", function(sid,  _, _, _, _)
	return !table.HasValue(Players, sid)
end)

I just tested it on singleplayer and found out that it catches 2 invisible symbols.


local GroupPlayers = {}

--local Group = "http://steamcommunity.com/groups/Zuthar13#" // Name of the group ie <a href="http://steamcommunity.com/groups/glua" target="_blank">http://steamcommunity.com/groups/glua</a>
local Group = "Anti-Matter_Gaming" --my group to test it
local num = 1

print("[GS] Running group script ..")
print("[GS] Fetching data ..")
 
local function Success( str, len, head, http )
        str = string.Replace(str, "</steamID64>", "")
       
        local tbl = string.Explode("<steamID64>", str)
       
        table.remove(tbl, 1)
       
        tbl[#tbl] = string.Replace(tbl[#tbl], "</members>", "")
        tbl[#tbl] = string.Replace(tbl[#tbl], "</memberList>", "")
       
        for k, v in pairs(tbl) do
                table.insert(GroupPlayers, string.sub(v,0,#v-2))
        end
		print("[GS] Added "..#tbl.." people.")
end
 
local function Success2( str, len, head, http )
        local tbl = string.Explode("<memberCount>", str)
       
        table.remove(tbl, 1)
       
        tbl = string.Explode("</memberCount>", tbl[2])
        num = string.Replace(tbl[1], "</memberCount>", "")
        num = math.Clamp(math.Round(tonumber(num) / 1000), 1, 1000)
       
        compile()
end
 
function compile()
	print("[GS] Found "..num.." member-page(s).")
        for i=1,num do
                http.Fetch("http://steamcommunity.com/groups/" .. Group .. "/memberslistxml/?xml=1&p=" .. i, Success, function() print("[GS] No data returned for memeberpage: "..num) end)
        end
end
http.Fetch("http://steamcommunity.com/groups/" .. Group .. "/memberslistxml/?xml=1", Success2, function() print("No data returned. Steam might be down.") end)

hook.Add("CheckPassword", "BadGroup", function(sid,  _, _, _, _)
	return !table.HasValue(GroupPlayers, sid)
end)

concommand.Add( "amIOnTheList", function( ply )
	if !ply then print("You're not a player, Console.") 
		return
	end
	local ID = (ply:SteamID64() or "SinglePlayerID")
	if table.HasValue(GroupPlayers, ID) then
		ply:ChatPrint("Yes you are "..ply:Nick()..".")
	else
		ply:ChatPrint("No. "..ply:Nick().." "..ID.." is not found.")
	end
end )

Try this script. It includes a debug command called “amIOnTheList” that you can type into the console once joined.

I dont think that the script is even loading there is nothing printing to console or my client and the concommand is not there.

What did you name the file where you saved the code?
The file must be unique, meaning no other file in existence inside Garry’s Mod can have that same name, if it’s in the base folder for server autorun (lua/autorun/server)

its named groupBlock.lua

You did restart you server after adding the file right?

yes, I have tried everything i have make it into addon format made the server include it i made the client download it and include it i put it in lua/autorun/server and in lua/autorun/client just to see if i can get it to work and nothing happens no errors or anything

All you should need to do, is place the lua file in lua/autorun/server. I tried it, and the console command worked and it printed to server console, but it did not detect me in a steam group that I was in.

First off no one should ever be downloading Lua files, second if it is not working I highley doubt there are no errors at all. Did you check the server console for any errors? Not all errors will appear on your in game console. If it turns out there really isn’t any errors then you screwed up placing the file. If you could post a screen shot of the exact file path you are using that might be helpful.

It did fetch all 327 members in one of my groups and detected me.

  • It won’t be 100% stable in large groups (500+)… since it tries to open 5-30 pages at the same time.
  • It won’t support singleplayer, as you got no steamID.

Also try compare the number of members with the server got. If it doesn’t match, you might be targeting the wrong group.

ok so i loaded it on my friends server with a better web console than nfo’s console and this is what i got

https://i.gyazo.com/31c95a8fa3fa4e9ae3fb1a5f54643f21.png