From 349bb41e7373acd814e6c6098e6deeba57bfc035 Mon Sep 17 00:00:00 2001 From: FekyDEV <71899549+FekyDEV@users.noreply.github.com> Date: Fri, 12 May 2023 22:55:40 +0200 Subject: [PATCH] Added option to externally cancel progress bar Personally, I think this feature should have been here a long time ago. I hope that adding this code will help players in the future and if anyone here has a suggestion for a code change feel free to comment. --- [core]/esx_progressbar/Progress.lua | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) diff --git a/[core]/esx_progressbar/Progress.lua b/[core]/esx_progressbar/Progress.lua index 96a638fb..08923692 100644 --- a/[core]/esx_progressbar/Progress.lua +++ b/[core]/esx_progressbar/Progress.lua @@ -1,4 +1,5 @@ local CurrentProgress = nil + local function Progressbar(message,length,Options) if CurrentProgress then return false @@ -34,9 +35,8 @@ local function Progressbar(message,length,Options) end end -ESX.RegisterInput("cancelprog", "[ProgressBar] Cancel Progressbar", "keyboard", "BACK", function() +local function CancelProgressbar() if not CurrentProgress then return end - if not CurrentProgress.onCancel then return end SendNUIMessage({ type = "Close" }) @@ -44,7 +44,12 @@ ESX.RegisterInput("cancelprog", "[ProgressBar] Cancel Progressbar", "keyboard", if CurrentProgress.FreezePlayer then FreezeEntityPosition(PlayerPedId(), false) end CurrentProgress.canceled = true CurrentProgress.length = 0 - CurrentProgress.onCancel() CurrentProgress = nil +end + +ESX.RegisterInput("cancelprog", "[ProgressBar] Cancel Progressbar", "keyboard", "BACK", function() + CancelProgressbar() end) + exports('Progressbar', Progressbar) +exports('CancelProgressbar', CancelProgressbar)