Add this to client.lua: (This opens the phone linked to an item)
ESX = nil
Citizen.CreateThread (function ()
while ESX == nil do
TriggerEvent (‘esx: getSharedObject’, function (obj) ESX = obj end)
Citizen.Wait (0)
end
end)
function hasPhone (cb)
if (ESX == nil) then return cb (0) end
ESX.TriggerServerCallback (‘gcphone: getItemAmount’, function (qtty)
cb (qtty> 0)
end, ‘phone’)
end
function ShowNoPhoneWarning ()
if (ESX == nil) then return end
ESX.ShowNotification (“You do not have a ~ r ~ phone ~ s ~”)
end
In the server side put:
local ESX = nil
TriggerEvent(‘esx:getSharedObject’, function(obj)
ESX = obj
ESX.RegisterServerCallback(‘gcphone:getItemAmount’, function(source, cb, item)
print('gcphone:getItemAmount call item : ’ … item)
local xPlayer = ESX.GetPlayerFromId(source)
local items = xPlayer.getInventoryItem(item)
if items == nil then
cb(0)
else
cb(items.count)
end
end)
end)
After that, in your Database, go to the items table, Right click inside and click “INSERT ROW” and set:
name: phone
label: Phone (Or whatever you want it to display as in your inventory)
limit: 1 (Unless you want them to be able to hold more than 1 item, but it’s useless to have more than 1 unless selling phones to people or buying one for a friend.)
And leave other options like “id” and “rare” and “can_remove” as default.