Skip to content

Commit

Permalink
Add sf_enabled_cl cvar (#1993)
Browse files Browse the repository at this point in the history
* Add sf_enabled_cl cvar

* Fix
  • Loading branch information
thegrb93 authored Jan 20, 2025
1 parent ef80fe9 commit 481f2e3
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 13 deletions.
23 changes: 10 additions & 13 deletions lua/entities/starfall_processor/init.lua
Original file line number Diff line number Diff line change
Expand Up @@ -84,20 +84,17 @@ end
function ENT:SendCode(recipient)
if not (IsValid(self.owner) or IsWorld(self.owner)) then return end
if not self.sfsenddata then return end
if self.sfownerdata then -- Send specific data for owner if there are owner-only files
local others = {}
for _, ply in ipairs(recipient and (istable(recipient) and recipient or { recipient }) or player.GetHumans()) do
if ply==self.owner then
SF.SendStarfall("starfall_processor_download", self.sfownerdata, self.owner)
else
others[#others+1] = ply
end
end
if #others > 0 then
SF.SendStarfall("starfall_processor_download", self.sfsenddata, others)
local others = {}
for _, ply in ipairs(recipient and (istable(recipient) and recipient or { recipient }) or player.GetHumans()) do
if ply:GetInfoNum("sf_enabled_cl", 0)==0 then continue end
if ply==self.owner and self.sfownerdata then
SF.SendStarfall("starfall_processor_download", self.sfownerdata, self.owner)
else
others[#others+1] = ply
end
else
SF.SendStarfall("starfall_processor_download", self.sfsenddata, recipient)
end
if #others > 0 then
SF.SendStarfall("starfall_processor_download", self.sfsenddata, others)
end
end

Expand Down
2 changes: 2 additions & 0 deletions lua/starfall/instance.lua
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ else
SF.softLockProtectionOwner = CreateConVar("sf_timebuffersoftlock_cl_owner", 1, FCVAR_ARCHIVE, "If sf_timebuffersoftlock_cl is 0, this enabled will make it only your own chips will be affected.")
SF.RamCap = CreateConVar("sf_ram_max_cl", 1500000, FCVAR_ARCHIVE, "If ram exceeds this limit (in kB), starfalls will be terminated")
SF.AllowSuperUser = CreateConVar("sf_superuserallowed", 0, {FCVAR_ARCHIVE, FCVAR_REPLICATED}, "Whether the starfall superuser feature is allowed")
SF.CvarEnabled = CreateConVar( "sf_enabled_cl", "1", { FCVAR_ARCHIVE, FCVAR_USERINFO, FCVAR_DONTRECORD }, "Enable clientside starfall" )
end
local ramlimit = SF.RamCap:GetInt()
cvars.AddChangeCallback(SF.RamCap:GetName(), function() ramlimit = SF.RamCap:GetInt() end)
Expand Down Expand Up @@ -57,6 +58,7 @@ function SF.Instance.Compile(code, mainfile, player, entity)
end
local ok, message = hook.Run("StarfallCanCompile", code, mainfile, player, entity)
if ok == false then return false, { message = message, traceback = "" } end
if CLIENT and not SF.CvarEnabled:GetBool() then return false, { message = "Clientside disabled", traceback = "" } end

local instance = setmetatable({}, SF.Instance)
instance.entity = entity
Expand Down

0 comments on commit 481f2e3

Please sign in to comment.