mirror of
https://github.com/esx-framework/esx_core.git
synced 2026-09-04 16:23:21 +00:00
refactor(esx_banking/client): refactor some if conditions
This commit is contained in:
@@ -74,7 +74,9 @@ local playerLoaded, uiActive, inMenu = false, false, false
|
|||||||
-- Handle text ui / Keypress
|
-- Handle text ui / Keypress
|
||||||
function BANK:TextUi(state, atm)
|
function BANK:TextUi(state, atm)
|
||||||
uiActive = state
|
uiActive = state
|
||||||
if state then
|
if not state then
|
||||||
|
return ESX.HideUI()
|
||||||
|
end
|
||||||
ESX.TextUI(TranslateCap('press_e_banking'))
|
ESX.TextUI(TranslateCap('press_e_banking'))
|
||||||
CreateThread(function()
|
CreateThread(function()
|
||||||
while uiActive do
|
while uiActive do
|
||||||
@@ -85,9 +87,6 @@ local playerLoaded, uiActive, inMenu = false, false, false
|
|||||||
Wait(0)
|
Wait(0)
|
||||||
end
|
end
|
||||||
end)
|
end)
|
||||||
else
|
|
||||||
ESX.HideUI()
|
|
||||||
end
|
|
||||||
end
|
end
|
||||||
|
|
||||||
-- Create Blips
|
-- Create Blips
|
||||||
@@ -127,7 +126,12 @@ local playerLoaded, uiActive, inMenu = false, false, false
|
|||||||
atm = atm or false
|
atm = atm or false
|
||||||
SetNuiFocus(state, state)
|
SetNuiFocus(state, state)
|
||||||
inMenu = state
|
inMenu = state
|
||||||
if state then
|
if not state then
|
||||||
|
SendNUIMessage({
|
||||||
|
showMenu = false
|
||||||
|
})
|
||||||
|
return
|
||||||
|
end
|
||||||
ESX.TriggerServerCallback('esx_banking:getPlayerData', function(data)
|
ESX.TriggerServerCallback('esx_banking:getPlayerData', function(data)
|
||||||
SendNUIMessage({
|
SendNUIMessage({
|
||||||
showMenu = true,
|
showMenu = true,
|
||||||
@@ -152,11 +156,6 @@ local playerLoaded, uiActive, inMenu = false, false, false
|
|||||||
}
|
}
|
||||||
})
|
})
|
||||||
end)
|
end)
|
||||||
else
|
|
||||||
SendNUIMessage({
|
|
||||||
showMenu = false
|
|
||||||
})
|
|
||||||
end
|
|
||||||
end
|
end
|
||||||
|
|
||||||
function BANK:LoadNpc(index, netID)
|
function BANK:LoadNpc(index, netID)
|
||||||
@@ -229,14 +228,19 @@ RegisterNUICallback('close', function(data, cb)
|
|||||||
end)
|
end)
|
||||||
|
|
||||||
RegisterNUICallback('clickButton', function(data, cb)
|
RegisterNUICallback('clickButton', function(data, cb)
|
||||||
if data ~= nil and inMenu then
|
if not data or not inMenu then
|
||||||
TriggerServerEvent("esx_banking:doingType", data)
|
return cb('ok')
|
||||||
end
|
end
|
||||||
|
|
||||||
|
TriggerServerEvent("esx_banking:doingType", data)
|
||||||
cb('ok')
|
cb('ok')
|
||||||
end)
|
end)
|
||||||
|
|
||||||
RegisterNUICallback('checkPincode', function(data, cb)
|
RegisterNUICallback('checkPincode', function(data, cb)
|
||||||
if data ~= nil and inMenu then
|
if not data or not inMenu then
|
||||||
|
return cb('ok')
|
||||||
|
end
|
||||||
|
|
||||||
ESX.TriggerServerCallback("esx_banking:checkPincode", function(pincode)
|
ESX.TriggerServerCallback("esx_banking:checkPincode", function(pincode)
|
||||||
if pincode then
|
if pincode then
|
||||||
cb({
|
cb({
|
||||||
@@ -251,5 +255,4 @@ RegisterNUICallback('checkPincode', function(data, cb)
|
|||||||
ESX.ShowNotification(TranslateCap('pincode_not_found'), "error")
|
ESX.ShowNotification(TranslateCap('pincode_not_found'), "error")
|
||||||
end
|
end
|
||||||
end, data)
|
end, data)
|
||||||
end
|
|
||||||
end)
|
end)
|
||||||
Reference in New Issue
Block a user