GKSHOP
Web StoreDiscord
  • 👋GKSHOP Documentation
  • INFORMATION
    • ⁉️FAQ
    • 💡Discord Roles
    • ⚠️FiveM Asset Escrow System
  • GKSPHONE v2
    • 📔Installation
    • ❓Documentation
    • 👷Exports
      • Client
      • Server
    • 🪛Custom App
    • Configuration
      • Unique phones
      • Custom inventory
      • Custom Wallpapers
      • Custom ringtones and notifications
      • Apps
      • Currency
    • Common Issues
    • 🚒Job Center
  • GKSPHONE v1
    • 📱ESX
      • 📔Installation
      • ❓Documentation
      • Application Usages
      • Developers
        • Server Event
        • Client Event
    • 📱QB
      • 📔Installation
      • ❓Documentation
      • Application Usages
      • Developers
        • Server Event
        • Client Event
  • Other Products
    • ⚒️GKSCRAFT
      • 📘Installation
      • Config
      • Developers
        • Server Event
    • ⛽GKS FUEL
      • 📔Installation
      • Config
      • Exports
    • 📸Media Services (GKSMEDIA)
    • 📲GKSPHONE Real App
  • OTHER
    • Policy
      • Privacy Policy
Powered by GitBook
On this page
  • Add to Config.lua
  • Create files
  1. GKSPHONE v1
  2. GKSPHONEv2
  3. Configuration

Custom inventory

This guide requires coding experience. We will not assist you in adding custom inventories.

Replace CustomInventory with the name of your inventory

Add to Config.lua

Config.CustomInventory = GetResourceState("CustomInventory") == 'started'

Create files

Create CustomInventory.lua file in gksphone/server/inventory and gksphone/client/inventory folders

  • When the phone item is deleted, the "gksphone:client:ItemRemoved" trigger must be fired. ( If your inventory does not support this feature, check other inventory files. )

  • It should work when the "UsePhoneItem" export phone element is used

  • — If there is no export support in the inventory, you can run it using server-side framework structures. ( Use RegisterUsableItem in ESX and CreateUseableItem in Qb-core )

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)

In the server section, ox_invetory examples are given in the export section. Integrate the exports of the CustomInventory into this section.

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
end

If you do not have an export as an opening function in your inventory, you can use the following functions


-- ESX
for index, _ in pairs(Config.ItemName) do
    Config.Core.RegisterUsableItem(index, function(source, item, data)
        debugprint("Item Check", source, item, data)
        TriggerClientEvent('gksphone:client:usePhone', source, index, data)
    end)
end

-- Qb
for index in pairs(Config.ItemName) do
    Config.Core.Functions.CreateUseableItem(index, function(source, item)
        TriggerClientEvent('gksphone:client:usePhone', source, item)
    end)
end

Last updated 3 months ago

📱