From c804945e00dec65e55854cebafafe7451237475d Mon Sep 17 00:00:00 2001 From: RockySouthpaw <55056068+RockySouthpaw@users.noreply.github.com> Date: Fri, 28 Aug 2020 23:06:29 -0400 Subject: [PATCH] Added a toggle comand, removed hide/open Command phone:open was used to open the phone and phone:hide was used to hide it. (Obviously kek) Consolodated it into one command. /phone. Removed the NUI Message from phone:send, but left the `TriggerEvent('phone:sendContacts')` --- resources/client/cl_main.lua | 50 +++++++++++++++++++++--------------- 1 file changed, 29 insertions(+), 21 deletions(-) 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( {