ULX

Author Topic: Banning family shared accounts of players that are already banned - Sourcebans  (Read 3850 times)

0 Members and 3 Guests are viewing this topic.

Offline Jerpy

  • Newbie
  • *
  • Posts: 21
  • Karma: 2
There have been various topics about this on facepunch, since it's definitely pretty mainstream now. Kids get banned, get bored, make another account, family share it, and bam. Ban avoided.

There was a script written that calls the steamAPI, as steam has blessed us with the function that searches for shared accounts.

The script works however it is only compatible with the ULib library of bans.

I use ULX, but I also use sourcebans. Lexi's module.

Because my bans are not stored in ULX/ULib, I need it to check the sbans database for the ban, and then proceed with the function of banning the player.

Here is the full script.

Code: [Select]
local APIKey = "api key here" -- See http://steamcommunity.com/dev/apikey

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 not (ULib and ULib.bans) then return end

    if ULib.bans[lenderSteamID] then
        --ply:Kick("The account that lent you Garry's Mod is banned on this server")
RunConsoleCommand("ulx sbanid "..ply:SteamID().."0 The account that lent you Garry's Mod is banned on this server")
    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)

My problem with lexi's module is that I just cannot figure out not only what banchecker to use, but how to retrieve the result from the query it sends.
I know it's possible, but I just can't figure out how.

Here is a paste of her module: http://pastebin.com/CzCE1qQC

I'd appreciate any help possible in this, since I really need this function on my servers after dealing with some bored kids that pulled this.

I would post this to facepunch, but at this point in time it's possible to get any help there without getting drilled with dumb ratings and leaving with zero help.

Thanks.

An Error Has Occurred!

array_keys(): Argument #1 ($array) must be of type array, null given