Skip to content

Instantly share code, notes, and snippets.

@BadgerCode
Last active August 16, 2025 11:53
Show Gist options
  • Save BadgerCode/a16b475a21a2233d699d092fde0497de to your computer and use it in GitHub Desktop.
Save BadgerCode/a16b475a21a2233d699d092fde0497de to your computer and use it in GitHub Desktop.
Checks if a user is using a family-shared copy of Garry's Mod from an account which is banned and then kicks them
-- 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)
@BadgerCode
Copy link
Author

BadgerCode commented Aug 6, 2024

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

@BadgerCode
Copy link
Author

Updated to use Player:OwnerSteamID64

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment