Skip to content

Commit ac326a6

Browse files
authored
Merge pull request #328 from Jazzelhawk/holo_timer
Added convar for hologram burst counter timer delay
2 parents 5b402c4 + cf1a2f8 commit ac326a6

1 file changed

Lines changed: 10 additions & 2 deletions

File tree

lua/starfall/libs_sv/holograms.lua

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,13 @@ SF.Holograms.personalquota = CreateConVar( "sf_holograms_personalquota", "300",
1818
SF.Holograms.burstrate = CreateConVar( "sf_holograms_burstrate", "10", { FCVAR_ARCHIVE, FCVAR_REPLICATED },
1919
"The default number of holograms allowed to spawn in a short interval of time via Starfall scripts for a single instance ( burst )" )
2020

21+
SF.Holograms.timerdelay = CreateConVar( "sf_holograms_timerdelay", "0.25", {FCVAR_ARCHIVE,FCVAR_REPLICATED},
22+
"The default rate at which the burst counter is reduced ( rate at which players can spawn holograms )" )
23+
24+
cvars.AddChangeCallback( "sf_holograms_timerdelay", function ()
25+
timer.Adjust( "SF_Hologram_BurstCounter", SF.Holograms.timerdelay:GetFloat() or 1/4, 0, burstCounter )
26+
end )
27+
2128
SF.Holograms.Methods = hologram_methods
2229
SF.Holograms.Metatable = hologram_metamethods
2330

@@ -277,13 +284,14 @@ local function personal_max_reached ( i )
277284
return plyCount[ i.player ] >= SF.Holograms.personalquota:GetInt()
278285
end
279286

280-
timer.Create( "SF_Hologram_BurstCounter", 1/4, 0, function ()
287+
local function burstCounter ()
281288
for i, _ in pairs( insts ) do
282289
if i.data.holograms.burst < SF.Holograms.burstrate:GetInt() or 10 then -- Should allow for dynamic changing of burst rate from the server.
283290
i.data.holograms.burst = i.data.holograms.burst + 1
284291
end
285292
end
286-
end )
293+
end
294+
timer.Create( "SF_Hologram_BurstCounter", SF.Holograms.timerdelay:GetFloat() or 1/4, 0, burstCounter )
287295

288296
--- Creates a hologram.
289297
-- @server

0 commit comments

Comments
 (0)