From 732ca2385b7fd9d7ad259c99826909e3c68dbcbd Mon Sep 17 00:00:00 2001 From: renaiku Date: Mon, 7 Aug 2017 23:36:23 +0200 Subject: [PATCH] ATM opening in every marker zone bug correction. --- client/esx_atm_cl.lua | 30 +++++++++++++++++------------- 1 file changed, 17 insertions(+), 13 deletions(-) diff --git a/client/esx_atm_cl.lua b/client/esx_atm_cl.lua index 89e9eabb..e096e28a 100644 --- a/client/esx_atm_cl.lua +++ b/client/esx_atm_cl.lua @@ -1,6 +1,7 @@ local GUI = {} local hasAlreadyEnteredMarker = false -GUI.MenuIsShowed = false +local isInATMMarker = false +local menuIsShowed = false ESX = nil @@ -11,10 +12,14 @@ Citizen.CreateThread(function() end end) +TriggerEvent('es:setDefaultSettings', { + nativeMoneySystem = false, +}) + RegisterNetEvent('esx_atm:closeATM') AddEventHandler('esx_atm:closeATM', function() SetNuiFocus(false) - GUI.MenuIsShowed = false + menuIsShowed = false SendNUIMessage({ hideAll = true }) @@ -67,24 +72,23 @@ end) Citizen.CreateThread(function() while true do Wait(0) - local coords = GetEntityCoords(GetPlayerPed(-1)) - local isInMarker = false + local coords = GetEntityCoords(GetPlayerPed(-1)) + isInATMMarker = false for i=1, #Config.ATMS, 1 do if(GetDistanceBetweenCoords(coords, Config.ATMS[i].x, Config.ATMS[i].y, Config.ATMS[i].z, true) < Config.ZoneSize.x / 2) then - isInMarker = true + isInATMMarker = true SetTextComponentFormat('STRING') AddTextComponentString('Appuyez sur ~INPUT_PICKUP~ pour déposer ou retirer du ~g~cash~s~.') DisplayHelpTextFromStringLabel(0, 0, 1, -1) end end - if isInMarker and not hasAlreadyEnteredMarker then + if isInATMMarker and not hasAlreadyEnteredMarker then hasAlreadyEnteredMarker = true - --TriggerEvent('esx_atm:hasEnteredMarker') end - if not isInMarker and hasAlreadyEnteredMarker then + if not isInATMMarker and hasAlreadyEnteredMarker then hasAlreadyEnteredMarker = false SetNuiFocus(false) - GUI.MenuIsShowed = false + menuIsShowed = false SendNUIMessage({ hideAll = true }) @@ -96,7 +100,7 @@ end) Citizen.CreateThread(function() while true do Wait(0) - if GUI.MenuIsShowed then + if menuIsShowed then DisableControlAction(0, 1, true) -- LookLeftRight DisableControlAction(0, 2, true) -- LookUpDown DisableControlAction(0, 142, true) -- MeleeAttackAlternate @@ -107,8 +111,8 @@ Citizen.CreateThread(function() }) end else - if IsControlJustReleased(0, 38) then - GUI.MenuIsShowed = true + if IsControlJustReleased(0, 38) and isInATMMarker then + menuIsShowed = true ESX.TriggerServerCallback('esx:getPlayerData', function(data) SendNUIMessage({ showMenu = true, @@ -122,4 +126,4 @@ Citizen.CreateThread(function() end end end -end) +end) \ No newline at end of file