diff --git a/README.md b/README.md index 48a4b87..b617b78 100644 --- a/README.md +++ b/README.md @@ -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 diff --git a/lua/afsu/server/concmd/toggle/sv_family_share.lua b/lua/afsu/server/concmd/toggle/sv_family_share.lua new file mode 100644 index 0000000..1679170 --- /dev/null +++ b/lua/afsu/server/concmd/toggle/sv_family_share.lua @@ -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)