-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Added family share protection module
- Loading branch information
1 parent
6720599
commit 4aa9522
Showing
2 changed files
with
41 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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) |