From 58ad54eac40df337edbdfe4bda092f14d57b3491 Mon Sep 17 00:00:00 2001 From: Nullified <28195796+Gittified@users.noreply.github.com> Date: Mon, 3 Oct 2022 16:26:27 +0200 Subject: [PATCH] refactor(esx_holdup/client): improved thread sleeping Moved the holdingUp toggle to the thread where the server event is triggered if the user is too far. Also improved thread sleeping so it turns on when the user is out of range and toggles once the robbery is canceled. --- [esx_addons]/esx_holdup/client/main.lua | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/[esx_addons]/esx_holdup/client/main.lua b/[esx_addons]/esx_holdup/client/main.lua index 6f8d33ab..28de0d68 100644 --- a/[esx_addons]/esx_holdup/client/main.lua +++ b/[esx_addons]/esx_holdup/client/main.lua @@ -37,7 +37,7 @@ end) RegisterNetEvent('esx_holdup:tooFar') AddEventHandler('esx_holdup:tooFar', function() - holdingUp, store = false, '' + store = '' ESX.ShowNotification(_U('robbery_cancelled')) end) @@ -100,12 +100,15 @@ CreateThread(function() end end break + else + letSleep = true end end if holdingUp then letSleep = false if #(playerPos - Stores[store].position) > Config.MaxDistance then TriggerServerEvent('esx_holdup:tooFar', store) + holdingUp, letSleep = false, true end end if letSleep then