mirror of
https://github.com/darksaid98/new-phone-who-dis.git
synced 2026-12-04 22:16:40 +00:00
(Feature): Added phone as an item
This commit is contained in:
1 parent
b478f16fec
commit
808315921b
3 files changed
+69
No files matched your search
@@ -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,6 +159,10 @@ Citizen.CreateThread(function()
|
|||||||
end)
|
end)
|
||||||
|
|
||||||
function Phone() --Open/close phone
|
function Phone() --Open/close phone
|
||||||
|
if Config.PhoneAsItem == true then
|
||||||
|
--print("ConfigOn")
|
||||||
|
carryingPhone(function (carryingPhone)
|
||||||
|
if carryingPhone == true then
|
||||||
if isPhoneOpen == false then
|
if isPhoneOpen == false then
|
||||||
isPhoneOpen = true
|
isPhoneOpen = true
|
||||||
phoneOpenAnim()
|
phoneOpenAnim()
|
||||||
@@ -171,6 +192,42 @@ function Phone() --Open/close phone
|
|||||||
SetNuiFocus(false, false)
|
SetNuiFocus(false, false)
|
||||||
phoneCloseAnim()
|
phoneCloseAnim()
|
||||||
end
|
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
|
||||||
|
|
||||||
RegisterCommand('phone', function(source) -- Toggles Phone
|
RegisterCommand('phone', function(source) -- Toggles Phone
|
||||||
|
|||||||
@@ -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
|
||||||
@@ -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)
|
||||||
Reference in new issue
Block a user