(Fix): Made function for toggle phone.

This commit is contained in:
RockySouthpaw committed 2020-09-09 15:51:37 -04:00
1 parent dd89131d10
commit b478f16fec
1 file changed
+8 -42
+8 -42
View File
@@ -135,42 +135,13 @@ end
Citizen.CreateThread(function() Citizen.CreateThread(function()
while true do while true do
Citizen.Wait(0) Citizen.Wait(0)
if IsControlJustPressed(1, Config.KeyTogglePhone) then if IsControlJustPressed(1, Config.KeyTogglePhone) then
if isPhoneOpen == false then Phone()
isPhoneOpen = true
print(Config.KeyTogglePhone) --Left for testing purposes.
phoneOpenAnim()
SetCursorLocation(0.936, 0.922) -- Experimental
local res = GetActiveScreenResolution()
--print(res)
SendNUIMessage( -- Shows phone
{
app = 'PHONE',
method = 'setVisibility',
data = true
}
)
SetNuiFocus(true, true)
TriggerServerEvent('phone:getCredentials', source)
elseif isPhoneOpen == true then
isPhoneOpen = false
print(Config.KeyTogglePhone) --Left for testing purposes.
phoneCloseAnim()
SendNUIMessage( -- Hides phone
{
app = 'PHONE',
method = 'setVisibility',
data = false
}
)
SetNuiFocus(false, false)
end
end end
end end
end) end)
RegisterCommand('phone', function(source) -- Toggles Phone function Phone() --Open/close phone
if isPhoneOpen == false then if isPhoneOpen == false then
isPhoneOpen = true isPhoneOpen = true
phoneOpenAnim() phoneOpenAnim()
@@ -200,6 +171,10 @@ RegisterCommand('phone', function(source) -- Toggles Phone
SetNuiFocus(false, false) SetNuiFocus(false, false)
phoneCloseAnim() phoneCloseAnim()
end end
end
RegisterCommand('phone', function(source) -- Toggles Phone
Phone()
end, false) end, false)
@@ -209,16 +184,7 @@ AddEventHandler('phone:send', function()
end) end)
RegisterNUICallback('phone:close', function() -- Called for when the phone is closed via the UI. RegisterNUICallback('phone:close', function() -- Called for when the phone is closed via the UI.
isPhoneOpen = false Phone()
SendNUIMessage(
{
app = 'PHONE',
method = 'setVisibility',
data = false
}
)
SetNuiFocus(false, false)
phoneCloseAnim() -- Closes the phone and deletes the prop.
end) end)
RegisterNetEvent('phone:sendCredentials') RegisterNetEvent('phone:sendCredentials')