(Feature): Added phone as an item

This commit is contained in:
RockySouthpaw committed 2020-09-09 17:22:56 -04:00
1 parent b478f16fec
commit 808315921b
3 files changed
+97 -28

No files matched your search

+85 -28
View File
@@ -132,6 +132,23 @@ function phoneCloseAnim() --Phone Close Animation
end end
end end
function carryingPhone(cb)
cb(true)
end
function carryingPhone(cb)
if (ESX == nil) then return cb(0) end
ESX.TriggerServerCallback('phone:getItemAmount', function(qtty)
cb(qtty > 0)
end, 'phone')
end
function noPhone()
if (ESX == nil) then return end
--exports['mythic_notify']:SendAlert('error', 'Oi Mate, No El Telephono')
ESX.ShowNotification('Oi Mate, No El Telephono')
end
Citizen.CreateThread(function() Citizen.CreateThread(function()
while true do while true do
Citizen.Wait(0) Citizen.Wait(0)
@@ -142,34 +159,74 @@ Citizen.CreateThread(function()
end) end)
function Phone() --Open/close phone function Phone() --Open/close phone
if isPhoneOpen == false then if Config.PhoneAsItem == true then
isPhoneOpen = true --print("ConfigOn")
phoneOpenAnim() carryingPhone(function (carryingPhone)
print("phone is now open") --Left for testing purposes. if carryingPhone == true then
TriggerServerEvent('phone:getCredentials', source) if isPhoneOpen == false then
SetCursorLocation(0.936, 0.922) -- Experimental isPhoneOpen = true
local res = GetActiveScreenResolution() phoneOpenAnim()
--print(res) print("phone is now open") --Left for testing purposes.
SendNUIMessage( -- Shows phone TriggerServerEvent('phone:getCredentials', source)
{ SetCursorLocation(0.936, 0.922) -- Experimental
app = 'PHONE', local res = GetActiveScreenResolution()
method = 'setVisibility', --print(res)
data = true SendNUIMessage( -- Shows phone
} {
) app = 'PHONE',
SetNuiFocus(true, true) method = 'setVisibility',
else data = true
isPhoneOpen = false }
print("phone is now closed") --Left for testing purposes. )
SendNUIMessage( -- Hides phone SetNuiFocus(true, true)
{ else
app = 'PHONE', isPhoneOpen = false
method = 'setVisibility', print("phone is now closed") --Left for testing purposes.
data = false SendNUIMessage( -- Hides phone
} {
) app = 'PHONE',
SetNuiFocus(false, false) method = 'setVisibility',
phoneCloseAnim() data = false
}
)
SetNuiFocus(false, false)
phoneCloseAnim()
end
else
noPhone()
end
end)
elseif Config.PhoneAsItem == false then
--print("ConfigOff")
if isPhoneOpen == false then
isPhoneOpen = true
phoneOpenAnim()
print("phone is now open") --Left for testing purposes.
TriggerServerEvent('phone:getCredentials', source)
SetCursorLocation(0.936, 0.922) -- Experimental
local res = GetActiveScreenResolution()
--print(res)
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)
phoneCloseAnim()
end
end end
end end
+1
View File
@@ -4,3 +4,4 @@ Config.Locale = 'en'
Config.KeyTogglePhone = 288 -- F1 Config.KeyTogglePhone = 288 -- F1
Config.KeyTakeCall = 38 -- E Config.KeyTakeCall = 38 -- E
Config.PhoneAsItem = true
+11
View File
@@ -30,3 +30,14 @@ RegisterCommand('getnumber', function(source, args)
local _identifier = xPlayer.getIdentifier() local _identifier = xPlayer.getIdentifier()
print(_identifier) print(_identifier)
end) end)
ESX.RegisterServerCallback('phone:getItemAmount', function(source, cb, item)
local xPlayer = ESX.GetPlayerFromId(source)
local items = xPlayer.getInventoryItem(item)
if items == nil then
cb(0)
else
cb(items.count)
end
end)