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.
This commit is contained in:
Nullified
2022-10-03 16:26:27 +02:00
committed by GitHub
parent c8f062b4ff
commit 58ad54eac4
+4 -1
View File
@@ -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