mirror of
https://github.com/esx-framework/esx_core.git
synced 2026-08-29 02:01:31 +00:00
Fix progressbar always return false|nil
This commit is contained in:
@@ -1,5 +1,36 @@
|
||||
---@class ProgressBarAnimation
|
||||
---@field public type "anim" | "Scenario"
|
||||
---@field public dict? string
|
||||
---@field public lib? string
|
||||
|
||||
---@class ProgressBarOptions
|
||||
---@field public animation ProgressBarAnimation
|
||||
---@field public FreezePlayer? boolean
|
||||
---@field public onFinish? function
|
||||
|
||||
local CurrentProgress = nil
|
||||
|
||||
local function startProcessing()
|
||||
while (CurrentProgress ~= nil) do
|
||||
if CurrentProgress.length > 0 then
|
||||
CurrentProgress.length = CurrentProgress.length - 1000
|
||||
else
|
||||
ClearPedTasks(ESX.PlayerData.ped)
|
||||
if CurrentProgress.FreezePlayer then
|
||||
FreezeEntityPosition(ESX.PlayerData.ped, false)
|
||||
end
|
||||
if CurrentProgress.onFinish then
|
||||
CurrentProgress.onFinish()
|
||||
end
|
||||
CurrentProgress = nil
|
||||
end
|
||||
Wait(1000)
|
||||
end
|
||||
end
|
||||
|
||||
---@param message string
|
||||
---@param length? number Timeout in milliseconds
|
||||
---@param Options? ProgressBarOptions
|
||||
local function Progressbar(message, length, Options)
|
||||
if CurrentProgress then
|
||||
return false
|
||||
@@ -24,21 +55,8 @@ local function Progressbar(message, length, Options)
|
||||
message = message or "ESX-Framework",
|
||||
})
|
||||
CurrentProgress.length = length or 3000
|
||||
while CurrentProgress ~= nil do
|
||||
if CurrentProgress.length > 0 then
|
||||
CurrentProgress.length = CurrentProgress.length - 1000
|
||||
else
|
||||
ClearPedTasks(ESX.PlayerData.ped)
|
||||
if CurrentProgress.FreezePlayer then
|
||||
FreezeEntityPosition(ESX.PlayerData.ped, false)
|
||||
end
|
||||
if CurrentProgress.onFinish then
|
||||
CurrentProgress.onFinish()
|
||||
end
|
||||
CurrentProgress = nil
|
||||
end
|
||||
Wait(1000)
|
||||
end
|
||||
CreateThread(startProcessing);
|
||||
return true;
|
||||
end
|
||||
|
||||
local function CancelProgressbar()
|
||||
|
||||
Reference in New Issue
Block a user