From 09ba32342cadbbd4fae19c68e485c43ae686cc2f Mon Sep 17 00:00:00 2001 From: Austin Dunn <60995067+Demigod916@users.noreply.github.com> Date: Sat, 1 Jun 2024 05:45:10 -0600 Subject: [PATCH] fix(timer): accessing private variable out of scope (#591) --- imports/timer/shared.lua | 18 ++++++------------ 1 file changed, 6 insertions(+), 12 deletions(-) diff --git a/imports/timer/shared.lua b/imports/timer/shared.lua index 04dbfb2..d3ed76b 100644 --- a/imports/timer/shared.lua +++ b/imports/timer/shared.lua @@ -41,28 +41,22 @@ function timer:start(async) self.private.startTime = GetGameTimer() - local function tick(instance) - while true do - while instance.private.paused do + local function tick() + while self:getTimeLeft('ms') > 0 do + while self:isPaused() do Wait(0) end - - if instance:getTimeLeft('ms') <= 0 then - break - end - Wait(0) end + self:onEnd() end if async then Citizen.CreateThreadNow(function() - tick(self) - self:onEnd() + tick() end) else - tick(self) - self:onEnd() + tick() end end