Skip to content

Commit 831bc00

Browse files
authored
Add e2 timer limit convar (#3196)
1 parent a735a00 commit 831bc00

File tree

1 file changed

+6
-0
lines changed
  • lua/entities/gmod_wire_expression2/core

1 file changed

+6
-0
lines changed

lua/entities/gmod_wire_expression2/core/timer.lua

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22
Timer support
33
\******************************************************************************/
44

5+
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")
56
local timerid = 0
67

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

91+
local timerLimit = wire_expression2_timers_limit:GetInt()
92+
if table.Count(luaTimers[entIndex]) >= timerLimit then
93+
return self:throw("Timer limit reached (" .. timerLimit .. ")", nil)
94+
end
95+
9096
local internalName = luaTimerGetInternalName(self.entity:EntIndex(), name)
9197
local callback, ent = callback:Unwrap("", self), self.entity
9298

0 commit comments

Comments
 (0)