Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add e2 timer limit convar #3196

Merged
merged 1 commit into from
Dec 2, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Loading