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:
[url]http://facepunch.com/showthread.php?t=1341204&p=43469693&viewfull=1#post43469693[/url]
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: [url]http://lex.me.uk/modules/sourcebans.lua[/url]
Here is how far I've gotten with changing it to a ban with sourcebans.
[CODE]
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\n", 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)\n", ply:Nick(), ply:SteamID(), code))
end
)
end
hook.Add("PlayerAuthed", "CheckFamilySharing", CheckFamilySharing)
[/CODE]
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.
CheckForBan takes in a function as its second argument for the callback. The callback is called with one argument: a boolean indicating whether the user was banned or not. If the person lending out the game is not banned, we don't do anything. If they are banned, we then check the connecting account to make sure that they're not already banned before banning them to avoid duplicates.
[code]
local steamid = ply:SteamID() -- Save this in case we lose the player object between the two callbacks
sourcebans.CheckForBan(lenderSteamID, function(banned)
if not banned then return end -- The sharer is not banned, no need to do anything else.
sourcebans.CheckForBan(steamid, function(banned)
if banned then return end -- The person receiving the shared game is already banned, don't ban then again
RunConsoleCommand("ulx", "sbanid", ply:SteamID(), 0, "Sharing account with banned SteamID: "..lenderSteamID)
end)
end)
[/code]
[QUOTE=xaviergmail;48420435]CheckForBan takes in a function as its second argument for the callback. The callback is called with one argument: a boolean indicating whether the user was banned or not. If the person lending out the game is not banned, we don't do anything. If they are banned, we then check the connecting account to make sure that they're not already banned before banning them to avoid duplicates.
[code]
local steamid = ply:SteamID() -- Save this in case we lose the player object between the two callbacks
sourcebans.CheckForBan(lenderSteamID, function(banned)
if not banned then return end -- The sharer is not banned, no need to do anything else.
sourcebans.CheckForBan(steamid, function(banned)
if banned then return end -- The person receiving the shared game is already banned, don't ban then again
RunConsoleCommand("ulx", "sbanid", ply:SteamID(), 0, "Sharing account with banned SteamID: "..lenderSteamID)
end)
end)
[/code][/QUOTE]
Worked great! Thanks a ton!
Sorry, you need to Log In to post a reply to this thread.