Merge pull request #1842 from seltonmt012/fix/progressbar-timing

fix(esx_progressbar): honour the requested duration and ignore cancelled runs
This commit is contained in:
_Not_
2026-08-14 19:39:45 -05:00
committed by GitHub
+13 -6
View File
@@ -9,11 +9,12 @@
---@field public onFinish? function
local CurrentProgress = nil
local progressCount = 0
local function startProcessing()
while (CurrentProgress ~= nil) do
if CurrentProgress.length > 0 then
CurrentProgress.length = CurrentProgress.length - 1000
local function startProcessing(id)
while CurrentProgress ~= nil and CurrentProgress.id == id do
if GetGameTimer() < CurrentProgress.finishAt then
Wait(50)
else
ClearPedTasks(ESX.PlayerData.ped)
if CurrentProgress.FreezePlayer then
@@ -24,7 +25,6 @@ local function startProcessing()
end
CurrentProgress = nil
end
Wait(1000)
end
end
@@ -55,8 +55,15 @@ local function Progressbar(message, length, Options)
length = length or 3000,
message = message or "ESX-Framework",
})
progressCount = progressCount + 1
CurrentProgress.id = progressCount
CurrentProgress.length = length or 3000
CreateThread(startProcessing);
CurrentProgress.finishAt = GetGameTimer() + CurrentProgress.length
local id = progressCount
CreateThread(function()
startProcessing(id)
end)
return true;
end