diff --git a/lua/entities/gmod_wire_expression2/core/timer.lua b/lua/entities/gmod_wire_expression2/core/timer.lua index 3b2a51f3bf..831baa6541 100644 --- a/lua/entities/gmod_wire_expression2/core/timer.lua +++ b/lua/entities/gmod_wire_expression2/core/timer.lua @@ -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) @@ -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