Custom inventory
Add to Config.lua
Config.CustomInventory = GetResourceState("CustomInventory") == 'started'Create files
if not Config.CustomInventory then return end
RegisterNetEvent("gksphone:client:ItemRemoved", function(item)
Wait(500)
if PhoneUniqueId and lastItemData and lastItemData.name == item then
ItemPhoneDeleted()
end
end)
exports("UsePhoneItem", function(data, itemData)
--data = {name = 'phone', label = 'Phone', slot = 1, count = 1}
--itemData = {name = 'phone', slot = 1, metadata = {phoneID = 'GKS202501HM1D', eSIMNumber = '28946041', phoneLang = 'en'}}
TriggerEvent("gksphone:client:usePhone", data.name, itemData)
end)if not Config.CustomInventory then return end
-- Required if meta is active
function SetItemData(source, item, data)
local src = source
exports.ox_inventory:SetMetadata(src, item.slot, data)
return true
end
-- Required if meta is active
function UpdateItemData(source, item, datatype, data)
local src = source
local metadata = item.metadata or item.info
metadata[datatype] = data
exports.ox_inventory:SetMetadata(src, item.slot, metadata)
end
--- Searches the player's inventory for the specified item.
function SearchPhoneItems(source)
local src = source
local Player = Config.Core.GetPlayerFromId(src)
local itemData = {}
if Player then
for k, _ in pairs(Config.ItemName) do
itemData = exports.ox_inventory:Search(src, 'slots', k)
if #itemData > 0 then
break
end
end
if #itemData > 0 then
return itemData
end
end
return itemData
endLast updated