From af2f506110f722c34895c7f51ef023b24a31ebe9 Mon Sep 17 00:00:00 2001 From: ElPumpo Date: Sun, 11 Nov 2018 12:06:03 +0100 Subject: [PATCH] Further performance improvements --- client/main.lua | 46 +++++++++++++++++++++++----------------------- config.lua | 3 ++- 2 files changed, 25 insertions(+), 24 deletions(-) diff --git a/client/main.lua b/client/main.lua index 5d519238..f2ed0d5a 100644 --- a/client/main.lua +++ b/client/main.lua @@ -73,10 +73,9 @@ Citizen.CreateThread(function() isInATMMarker = false for k,v in pairs(Config.ATMLocations) do - if(GetDistanceBetweenCoords(coords, v.x, v.y, v.z, true) < Config.ZoneSize.x / 2) then - isInATMMarker = true - ESX.ShowHelpNotification(_U('press_e_atm')) - canSleep = false + if GetDistanceBetweenCoords(coords, v.x, v.y, v.z, true) < 1.0 then + isInATMMarker, canSleep = true, true + break end end @@ -107,31 +106,32 @@ Citizen.CreateThread(function() while true do Citizen.Wait(10) - if menuIsShowed then - DisableControlAction(0, 1, true) -- LookLeftRight - DisableControlAction(0, 2, true) -- LookUpDown - DisableControlAction(0, 142, true) -- MeleeAttackAlternate - DisableControlAction(0, 106, true) -- VehicleMouseControlOverride - elseif IsControlJustReleased(0, Keys['E']) and isInATMMarker and IsPedOnFoot(PlayerPedId()) then - menuIsShowed = true - ESX.TriggerServerCallback('esx:getPlayerData', function(data) - SendNUIMessage({ - showMenu = true, - player = { - money = data.money, - accounts = data.accounts - } - }) - end) + if isInATMMarker and not menuIsShowed then - SetNuiFocus(true, true) - elseif (not isInATMMarker and not menuIsShowed) then + ESX.ShowHelpNotification(_U('press_e_atm')) + + if IsControlJustReleased(0, Keys['E']) and IsPedOnFoot(PlayerPedId()) then + menuIsShowed = true + ESX.TriggerServerCallback('esx:getPlayerData', function(data) + SendNUIMessage({ + showMenu = true, + player = { + money = data.money, + accounts = data.accounts + } + }) + end) + + SetNuiFocus(true, true) + end + + else Citizen.Wait(500) end end end) --- close the menu when script is restarting to avoid being stuck in NUI focus +-- close the menu when script is stopping to avoid being stuck in NUI focus AddEventHandler('onResourceStop', function(resource) if resource == GetCurrentResourceName() then if menuIsShowed then diff --git a/config.lua b/config.lua index 23d784f4..2dec24e0 100644 --- a/config.lua +++ b/config.lua @@ -1,7 +1,8 @@ Config = {} -Config.ZoneSize = {x = 3.0, y = 3.0, z = 0.3} + Config.ZDiff = 2.0 Config.BlipSprite = 431 + Config.Locale = 'fr' Config.EnableBlips = false -- for some reason ATM blips are extremly buggy and will bug out the map