Advertisement
Guest User

Untitled

a guest
Jan 12th, 2015
613
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.49 KB | None | 0 0
  1. local APIKey = "your own api key here" -- See http://steamcommunity.com/dev/apikey
  2.  
  3. local function HandleSharedPlayer(ply, lenderSteamID)
  4. print(string.format("FamilySharing: %s | %s has been lent Garry's Mod by %s",
  5. ply:Nick(),
  6. ply:SteamID(),
  7. lenderSteamID
  8. ))
  9.  
  10. if not (ULib and ULib.bans) then return end
  11.  
  12. if ULib.bans[lenderSteamID] then
  13. ply:Kick("The account that lent you Garry's Mod is banned on this server")
  14. end
  15. end
  16.  
  17. local function CheckFamilySharing(ply)
  18. http.Fetch(
  19. string.format("http://api.steampowered.com/IPlayerService/IsPlayingSharedGame/v0001/?key=%s&format=json&steamid=%s&appid_playing=4000",
  20. APIKey,
  21. ply:SteamID64()
  22. ),
  23.  
  24. function(body)
  25. body = util.JSONToTable(body)
  26.  
  27. if not body or not body.response or not body.response.lender_steamid then
  28. error(string.format("FamilySharing: Invalid Steam API response for %s | %s\n", ply:Nick(), ply:SteamID()))
  29. end
  30.  
  31. local lender = body.response.lender_steamid
  32. if lender ~= "0" then
  33. HandleSharedPlayer(ply, util.SteamIDFrom64(lender))
  34. end
  35. end,
  36.  
  37. function(code)
  38. error(string.format("FamilySharing: Failed API call for %s | %s (Error: %s)\n", ply:Nick(), ply:SteamID(), code))
  39. end
  40. )
  41. end
  42.  
  43. hook.Add("PlayerAuthed", "CheckFamilySharing", CheckFamilySharing)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement