Skip to content

Commit

Permalink
Changed to replicated convar
Browse files Browse the repository at this point in the history
  • Loading branch information
NickCloudAT committed Jan 4, 2025
1 parent 38f37af commit de85bb7
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 12 deletions.
12 changes: 1 addition & 11 deletions gamemodes/terrortown/gamemode/server/sv_propspec.lua
Original file line number Diff line number Diff line change
Expand Up @@ -9,9 +9,7 @@ local timer = timer

PROPSPEC = {}

---
-- @realm server
local cvPropspecToggle = CreateConVar("ttt_spec_prop_control", "1", { FCVAR_NOTIFY, FCVAR_ARCHIVE })
local cvPropspecToggle = GetConVar("ttt_spec_prop_control")

---
-- @realm server
Expand All @@ -31,14 +29,6 @@ local cvPropspecMax = CreateConVar("ttt_spec_prop_maxbonus", "16", { FCVAR_NOTIF
local cvPropspecDashMulitplier =
CreateConVar("ttt_spec_prop_dash", "2", { FCVAR_NOTIFY, FCVAR_ARCHIVE })

hook.Add("TTT2SyncGlobals", "AddPropspecGlobals", function()
SetGlobalBool(cvPropspecToggle:GetName(), cvPropspecToggle:GetBool())
end)

cvars.AddChangeCallback(cvPropspecToggle:GetName(), function(cv, old, new)
SetGlobalBool(cvPropspecToggle:GetName(), tobool(tonumber(new)))
end)

---
-- Forces a @{Player} to spectate an @{Entity}
-- @param Player ply
Expand Down
3 changes: 3 additions & 0 deletions gamemodes/terrortown/gamemode/shared/sh_cvar_handler.lua
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,9 @@
-- @realm shared
CreateConVar("ttt2_radar_charge_time", "30", { FCVAR_NOTIFY, FCVAR_ARCHIVE, FCVAR_REPLICATED })

-- @realm shared
CreateConVar("ttt_spec_prop_control", "1", { FCVAR_NOTIFY, FCVAR_ARCHIVE, FCVAR_REPLICATED })

---
-- @realm shared
CreateConVar(
Expand Down
6 changes: 5 additions & 1 deletion lua/ttt2/libraries/keyhelp.lua
Original file line number Diff line number Diff line change
Expand Up @@ -349,7 +349,11 @@ function keyhelp.InitializeBasicKeys()
KEYHELP_CORE,
"label_keyhelper_possess_focus_entity",
function(client)
if not client:IsSpec() or IsValid(client:GetObserverTarget()) or not GetGlobalBool("ttt_spec_prop_control", true) then
if
not client:IsSpec()
or IsValid(client:GetObserverTarget())
or not GetConVar("ttt_spec_prop_control"):GetBool()
then
return
end

Expand Down

0 comments on commit de85bb7

Please sign in to comment.