From c5e750c6b27ad8d8813b8421252ae8cec0f9a010 Mon Sep 17 00:00:00 2001 From: RockySouthpaw <55056068+RockySouthpaw@users.noreply.github.com> Date: Sat, 29 Aug 2020 14:57:09 -0400 Subject: [PATCH] Add togglephone via keybind. Should owrk, but needs testing later. --RegisterKeyMapping('phone', _U('keymap_phone'), 'keyboard', '') is commented out for now as its essentially a keybind to do a command. --- resources/client/cl_main.lua | 45 +++++++++++++++++++++++++++++++----- 1 file changed, 39 insertions(+), 6 deletions(-) diff --git a/resources/client/cl_main.lua b/resources/client/cl_main.lua index 616cf63..4bc729b 100644 --- a/resources/client/cl_main.lua +++ b/resources/client/cl_main.lua @@ -6,13 +6,46 @@ Citizen.CreateThread(function() Citizen.Wait(0) end end) ------------------------------------------------------------------------- End of ESX - ---RegisterCommand('phone:get', function(source, args, rawCommand) --- TriggerServerEvent('phone:server:getCredentials') ---end, false) - +----- +--END OF ESX +----- local isPhoneOpen = false +--RegisterKeyMapping('phone', _U('keymap_phone'), 'keyboard', '') + +--[[RegisterCommand('phone:get', function(source, args, rawCommand) + riggerServerEvent('phone:server:getCredentials') +end, false)]] + +Citizen.CreateThread(function() + while true do + Citizen.Wait(10) + if IsControlJustPressed(1, Config.KeyTogglePhone) then + if isPhoneOpen == false then + isPhoneOpen = true + print(Config.KeyTogglePhone) --Left for testing purposes. + SendNUIMessage( -- Shows phone + { + app = 'PHONE', + method = 'setVisibility', + data = true + } + ) + SetNuiFocus(true, true) + elseif isPhoneOpen == true then + isPhoneOpen = false + print(Config.KeyTogglePhone) --Left for testing purposes. + SendNUIMessage( -- Hides phone + { + app = 'PHONE', + method = 'setVisibility', + data = false + } + ) + SetNuiFocus(false, false) + end + end + end +end) RegisterCommand('phone', function(source) -- Toggles Phone TriggerServerEvent('phone:getCredentials', source)