-
-
Save BadgerCode/a16b475a21a2233d699d092fde0497de to your computer and use it in GitHub Desktop.
-- This goes in: | |
-- lua/autorun/account-sharing.lua | |
-- Original post http://facepunch.com/showthread.php?t=1341204&p=43469693&viewfull=1#post43469693 | |
-- Credit to McSimp | |
-- Updated to use ply:OwnerSteamID64 by BadgerCode | |
local function CheckFamilySharing(ply) | |
-- If the player is being shared the game, this will be the other account's steam ID | |
-- Otherwise, it will be the player's own steam ID | |
local lenderSteamID = util.SteamIDFrom64(ply:OwnerSteamID64()) | |
local chatMessage = string.format("FamilySharing: %s (%s) has been lent Garry's Mod by %s", ply:Nick(), ply:SteamID(), lenderSteamID) | |
print(chatMessage) | |
if not (ULib and ULib.bans) then return end | |
local playerIsBanned = ULib.bans[lenderSteamID] | |
if playerIsBanned then | |
local banMessage = string.format("%s (%s) has been lent Garry's Mod by a banned account- %s", ply:Nick(), ply:SteamID(), lenderSteamID) | |
for i, ply in ipairs(player.GetHumans()) do | |
ply:ChatPrint(banMessage) | |
end | |
ply:Kick("The account that lent you Garry's Mod is banned on this server") | |
end | |
end | |
hook.Remove("PlayerAuthed", "CheckFamilySharing") | |
hook.Add("PlayerAuthed", "CheckFamilySharing", CheckFamilySharing) |
Yes I added the apikey to local and still a [sahaddon] addons/sahaddon/lua/sv_bans.lua:103: FamilySharing: Invalid Steam API response for |
error - [C]:-1
onsuccess - addons/sahaddon/lua/sv_bans.lua:103
3. unknown - lua/includes/modules/http.lua:69
SVBANS: safecrackSVBANS: lockpickSVBANS: caSVBANS: hacking[Player1|2|STEAM_0:1:91111823] Lua Error:
[ERROR] gamemodes/darkrp/gamemode/cl_options.lua:137: bad argument #1 to 'pairs' (table expected, got nil)
pairs - [C]:-1
LoadOptions - gamemodes/darkrp/gamemode/cl_options.lua:137
3. CreateOptionsMenuPanel - gamemodes/darkrp/gamemode/cl_mainmenu.lua:1208
4. ShowMainMenu - gamemodes/darkrp/gamemode/cl_mainmenu.lua:2729
5. unknown - gamemodes/darkrp/gamemode/cl_mainmenu.lua:2822
6. unknown - lua/includes/modules/concommand.lua:54
I've updated the code to have some better logging and error handling.
Could you update your copy of the code @isaac309 ?
I've updated the code to have some better logging and error handling. Could you update your copy of the code @isaac309 ?
Yes! The new code was a success erased the error. Thought it maybe could've been the firewall off the localhost, but it cleared right up! Thank you!
This no longer works as Valve have removed the API endpoint
https://developer.valvesoftware.com/w/index.php?title=Steam_Web_API&type=revision&diff=238804&oldid=230181
IsPlayingSharedGame
This could be re-written to use the newer, in-game method to retrieve this information
https://wiki.facepunch.com/gmod/Player:OwnerSteamID64
Updated to use Player:OwnerSteamID64
Hey @isaac309
On line 10, you need to replace
APIKEYGOESHERE
with your Steam API keyYou can get a Steam API key from here- http://steamcommunity.com/dev/apikey