So I tried getting help for this on ulyssesmod but the developer’s corner there is a bit dead, slightly.
Anyway, I’m using lexi’s sourcebans module for garry’s mod. It works just fine. I would like to integrate family sharing detection as people can easily avoid steamID bans via family sharing. Here is where I grabbed the code from:
The code works 100% for ULX bans, but we’re using a mysql connection here with sourcebans. Fortunately, lexi’s module has a built in function called CheckForBan. It’s at about line 691 here: http://lex.me.uk/modules/sourcebans.lua
Here is how far I’ve gotten with changing it to a ban with sourcebans.
local APIKey = "stuff" local function HandleSharedPlayer(ply, lenderSteamID) print(string.format("FamilySharing: %s | %s has been lent Garry's Mod by %s", ply:Nick(), ply:SteamID(), lenderSteamID )) if sourcebans.CheckForBan(lenderSteamID, callback) then RunConsoleCommand("ulx","sbanid",ply:SteamID(),0,"Sharing account with banned SteamID: "..lenderSteamID) end end local function CheckFamilySharing(ply) http.Fetch( string.format("http://api.steampowered.com/IPlayerService/IsPlayingSharedGame/v0001/?key=%s&format=json&steamid=%s&appid_playing=4000", APIKey, ply:SteamID64() ), function(body) body = util.JSONToTable(body) if not body or not body.response or not body.response.lender_steamid then error(string.format("FamilySharing: Invalid Steam API response for %s | %s ", ply:Nick(), ply:SteamID())) end local lender = body.response.lender_steamid if lender ~= "0" then HandleSharedPlayer(ply, util.SteamIDFrom64(lender)) end end, function(code) error(string.format("FamilySharing: Failed API call for %s | %s (Error: %s) ", ply:Nick(), ply:SteamID(), code)) end ) end hook.Add("PlayerAuthed", "CheckFamilySharing", CheckFamilySharing)
That’s set to ban by sbanid, because I use ULX integration for sourcebans. I figured just running the console command sbanid would be simpler.
As for the callback, what do I need to set there? Just checking “if sourcebans.CheckForBan(lenderSteamID) then” doesn’t work and errors with callback missing, so what would I put here?
Hopefully someone has an answer to this, thanks in advance.