Skip to content

Commit

Permalink
Add e2 timer limit convar (#3196)
Browse files Browse the repository at this point in the history
  • Loading branch information
wrefgtzweve authored Dec 2, 2024
1 parent a735a00 commit 831bc00
Showing 1 changed file with 6 additions and 0 deletions.
6 changes: 6 additions & 0 deletions lua/entities/gmod_wire_expression2/core/timer.lua
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
Timer support
\******************************************************************************/

local wire_expression2_timers_limit = CreateConVar("wire_expression2_timers_limit", 100, FCVAR_ARCHIVE, "The maximum number of timers that can be created by an E2 chip")
local timerid = 0

local function Execute(self, name)
Expand Down Expand Up @@ -87,6 +88,11 @@ local function luaTimerCreate(self, name, delay, repetitions, callback)
return self:throw("Timer with name " .. name .. " already exists", nil)
end

local timerLimit = wire_expression2_timers_limit:GetInt()
if table.Count(luaTimers[entIndex]) >= timerLimit then
return self:throw("Timer limit reached (" .. timerLimit .. ")", nil)
end

local internalName = luaTimerGetInternalName(self.entity:EntIndex(), name)
local callback, ent = callback:Unwrap("", self), self.entity

Expand Down

0 comments on commit 831bc00

Please sign in to comment.