Skip to content

Commit

Permalink
Added family share protection module
Browse files Browse the repository at this point in the history
  • Loading branch information
TwistedTail committed Jul 9, 2024
1 parent 6720599 commit 4aa9522
Show file tree
Hide file tree
Showing 2 changed files with 41 additions and 0 deletions.
4 changes: 4 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,10 @@ Same idea as the previous one, except with your loading screen. If there's at le
Incredibly, it's a fairly effective way to prevent server crashes by just spamming props since these will be frozen instantly. It can give your staff some seconds to react to this behavior. It currently covers props, SENTs, vehicles and ragdolls.
- This utility can be toggled with the console command `afsu toggle freeze_ents`.

### Steam Family Share prevention
Meant for those servers that are having issues with players rejoining under family shared accounts to evade bans, this feature will promptly get rid of them as soon as they're done loading.
- This utility is toggled `off` by the default and can be enabled with the console command `afsu toggle allow_family_share`.

## How to install this?

### The recommended way
Expand Down
37 changes: 37 additions & 0 deletions lua/afsu/server/concmd/toggle/sv_family_share.lua
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
local AFSU = AFSU
local ConsoleVar = CreateConVar("afsu_allow_family_share", "1", FCVAR_ARCHIVE)
local Allowed = ConsoleVar:GetBool()

local function PlayerAuthed(Player)
if Player:OwnerSteamID64() == Player:SteamID64() then return end

Player:Kick("Family Shared accounts are not allowed, please rejoin with the account that owns the game")
end

local function Initialize()
if not Allowed then
hook.Add("PlayerAuthed", "AFSU Family Share", PlayerAuthed)
end

hook.Remove("Initialize", "AFSU Family Share")
end

AFSU.NewToggleCommand("allow_family_share", function(Player)
local Toggled = not Allowed

ConsoleVar:SetBool(Toggled)

AFSU.SendMessage(Player, "Info", "Family Share protection toggled ", Toggled and "ON" or "OFF", ".")
end)

cvars.AddChangeCallback("afsu_allow_family_share", function(_, _, New)
Allowed = tobool(New)

if Allowed then
hook.Remove("PlayerAuthed", "AFSU Family Share")
else
hook.Add("PlayerAuthed", "AFSU Family Share", PlayerAuthed)
end
end)

hook.Add("Initialize", "AFSU Family Share", Initialize)

0 comments on commit 4aa9522

Please sign in to comment.