mirror of
https://github.com/esx-framework/esx_core.git
synced 2026-08-30 17:58:54 +00:00
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:
@@ -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
|
||||
|
||||
Reference in New Issue
Block a user