diff --git a/resources/client/cl_main.lua b/resources/client/cl_main.lua index fbf601a..448f31d 100644 --- a/resources/client/cl_main.lua +++ b/resources/client/cl_main.lua @@ -6,39 +6,47 @@ Citizen.CreateThread(function() Citizen.Wait(0) end end) +------------------------------------------------------------------------ End of ESX --RegisterCommand('phone:get', function(source, args, rawCommand) -- TriggerServerEvent('phone:server:getCredentials') --end, false) -RegisterCommand('phone:open', function(source, args, rawCommand) - TriggerServerEvent('phone:getCredentials', source) +local isPhoneOpen = false + +RegisterCommand('phone', function(source) -- Toggles Phone + TriggerServerEvent('phone:getCredentials', source) + if isPhoneOpen == false then + isPhoneOpen = true + print("phone is now open") --Left for testing purposes. + SendNUIMessage( -- Shows phone + { + app = 'PHONE', + method = 'setVisibility', + data = true + } + ) + SetNuiFocus(true, true) + else + isPhoneOpen = false + print("phone is now closed") --Left for testing purposes. + SendNUIMessage( -- Hides phone + { + app = 'PHONE', + method = 'setVisibility', + data = false + } + ) + SetNuiFocus(false, false) + end end, false) + RegisterNetEvent('phone:send') AddEventHandler('phone:send', function() - SendNUIMessage( - { - app = 'PHONE', - method = 'setVisibility', - data = true - } - ) - SetNuiFocus(true, true) TriggerEvent('phone:sendContacts') end) -RegisterCommand('phone:hide', function(source, args, rawCommand) - SendNUIMessage( - { - app = 'PHONE', - method = 'setVisibility', - data = false - } - ) - SetNuiFocus(false, false) -end, false) - RegisterNUICallback('phone:close', function() SendNUIMessage( {