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')`
This commit is contained in:
RockySouthpaw committed 2020-08-28 23:06:29 -04:00
1 parent c78eba04c9
commit c804945e00
1 file changed
+19 -11
+19 -11
View File
@@ -6,18 +6,20 @@ Citizen.CreateThread(function()
Citizen.Wait(0) Citizen.Wait(0)
end end
end) end)
------------------------------------------------------------------------ End of ESX
--RegisterCommand('phone:get', function(source, args, rawCommand) --RegisterCommand('phone:get', function(source, args, rawCommand)
-- TriggerServerEvent('phone:server:getCredentials') -- TriggerServerEvent('phone:server:getCredentials')
--end, false) --end, false)
RegisterCommand('phone:open', function(source, args, rawCommand) local isPhoneOpen = false
TriggerServerEvent('phone:getCredentials', source)
end, false)
RegisterNetEvent('phone:send') RegisterCommand('phone', function(source) -- Toggles Phone
AddEventHandler('phone:send', function() TriggerServerEvent('phone:getCredentials', source)
SendNUIMessage( if isPhoneOpen == false then
isPhoneOpen = true
print("phone is now open") --Left for testing purposes.
SendNUIMessage( -- Shows phone
{ {
app = 'PHONE', app = 'PHONE',
method = 'setVisibility', method = 'setVisibility',
@@ -25,11 +27,10 @@ AddEventHandler('phone:send', function()
} }
) )
SetNuiFocus(true, true) SetNuiFocus(true, true)
TriggerEvent('phone:sendContacts') else
end) isPhoneOpen = false
print("phone is now closed") --Left for testing purposes.
RegisterCommand('phone:hide', function(source, args, rawCommand) SendNUIMessage( -- Hides phone
SendNUIMessage(
{ {
app = 'PHONE', app = 'PHONE',
method = 'setVisibility', method = 'setVisibility',
@@ -37,8 +38,15 @@ RegisterCommand('phone:hide', function(source, args, rawCommand)
} }
) )
SetNuiFocus(false, false) SetNuiFocus(false, false)
end
end, false) end, false)
RegisterNetEvent('phone:send')
AddEventHandler('phone:send', function()
TriggerEvent('phone:sendContacts')
end)
RegisterNUICallback('phone:close', function() RegisterNUICallback('phone:close', function()
SendNUIMessage( SendNUIMessage(
{ {