• Print

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

0 Members and 1 Guest 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.

Offline Aaron113

  • Hero Member
  • *****
  • Posts: 803
  • Karma: 102
I'm going to go under the assumption that you are at least decent at Lua.

The two functions you are most likely looking for are sourcebans.GetAllBans(CALLBACK FUNCTION) and sourcebans.CheckForBan(STEAMID, CALLBACK FUNCTION)
Code: Lua
  1. ---
  2. -- Fetches all currently active bans in a table.
  3. -- If the ban was inacted by the server, the AdminID will be "STEAM_ID_SERVER".<br />
  4. -- If the server does not know who the admin who commited the ban is, the AdminID will be "STEAM_ID_UNKNOWN".<br/>
  5. -- Example table structure: <br/>
  6. -- <pre>{ <br/>
  7. -- &nbsp; BanStart = 1271453312, <br/>
  8. -- &nbsp; BanEnd = 1271453312, <br/>
  9. -- &nbsp; BanLength = 0, <br/>
  10. -- &nbsp; BanReason = "'Previously banned for repeately crashing the server'", <br/>
  11. -- &nbsp; IPAddress = "99.101.125.168", <br/>
  12. -- &nbsp; SteamID = "STEAM_0:0:20924001", <br/>
  13. -- &nbsp; Name = "MINOTAUR", <br/>
  14. -- &nbsp; AdminName = "Lexi", <br/>
  15. -- &nbsp; AdminID = "STEAM_0:1:16678762" <br/>
  16. -- }</pre> <br/>
  17. -- Bear in mind that SteamID or IPAddress may be a blank string.
  18. -- @param callback The function to be given the table
  19. function GetAllActiveBans(callback)
  20.     if (not callback) then
  21.         error("Function expected, got nothing!", 2);
  22.     elseif (not checkConnection()) then
  23.         return callback(false, "No Database Connection");
  24.     end
  25.     local query = database:query(queries["Get All Active Bans"]:format(config.dbprefix));
  26.     query.onSuccess = activeBansOnSuccess;
  27.     query.onFailure = activeBansOnFailure;
  28.     query.callback = callback;
  29.     query:start();
  30. end
^^^ Calls the callback function with a table of values listed above in the first parameter.  (Ex function(t) if t.SteamID == "STEAM" t.Name == "A-A-ron" then yayay end end )

Code: Lua
  1. ---
  2. -- Checks to see if a SteamID is banned from the system
  3. -- @param steamID The SteamID to check
  4. -- @param callback The callback function to tell the results to
  5. function CheckForBan(steamID, callback)
  6.     if (not checkConnection()) then
  7.         return callback(false, "No Database Connection");
  8.     elseif (not callback) then
  9.         error("Callback function required!", 2);
  10.     elseif (not steamID) then
  11.         error("SteamID required!", 2);
  12.     end
  13.     checkBanBySteamID(steamID, callback);
  14. end
^^^ Calls the callback function with a boolean as the first parameter.  (Ex function(isbanned) if isbanned then yayaya end end )

Offline Jerpy

  • Newbie
  • *
  • Posts: 21
  • Karma: 2
-snip-

solved this all on FP forums, issue is gone
« Last Edit: August 10, 2015, 06:35:22 am by Jerpy »

  • Print