Skip to content

Commit

Permalink
fix(timers): StopTimer not working - [Support Link](https://ptb.disco…
Browse files Browse the repository at this point in the history
  • Loading branch information
skuzzis committed Jan 2, 2025
1 parent 179e59b commit addd944
Showing 1 changed file with 11 additions and 9 deletions.
20 changes: 11 additions & 9 deletions plugin_files/bin/scripting/timers.lua
Original file line number Diff line number Diff line change
Expand Up @@ -22,22 +22,24 @@ function SetTimer(delay, callback)

timerIds = timerIds + 1

timersTable[timerIds] = {
id = timerIds,
local timerId = timerIds

timersTable[timerId] = {
id = timerId,
callback = callback,
timeoutFunction = function()
if timersTable[timerIds] then
timersTable[timerIds].callback()
if timersTable[timerIds] then
SetTimeout(delay, timersTable[timerIds].timeoutFunction)
if timersTable[timerId] then
timersTable[timerId].callback()
if timersTable[timerId] then
SetTimeout(delay, timersTable[timerId].timeoutFunction)
end
end
end
}

SetTimeout(delay, timersTable[timerIds].timeoutFunction)
SetTimeout(delay, timersTable[timerId].timeoutFunction)

return timerIds
return timerId
end

function StopTimer(timerId)
Expand All @@ -58,4 +60,4 @@ function NextTick(callback)
end

SetTimeout(1, callback)
end
end

0 comments on commit addd944

Please sign in to comment.