Integration
Inventory
How FX Phone reads the phone item from ox_inventory or QBCore inventories, and how to connect another inventory.
luaConfig.Item = 'phone' -- false: no item needed
Config.Inventory = 'auto' -- 'auto' | 'ox_inventory' | 'qb-inventory' | 'standalone'
Without the item a player cannot open the phone, does not hear notification sounds or ringtones, and confirmation requests from scripts answer false. Calls and messages still arrive; they are waiting when the phone is back. Losing the item while the phone is open closes it.
#Adapters
Config.Inventory |
Chosen by auto when |
Reads | Notices loss |
|---|---|---|---|
ox_inventory |
ox_inventory is installed | Search('count', item) |
ox_inventory:itemCount |
qb-inventory |
qb-core or qbx_core is installed, and ox_inventory is not | PlayerData.items |
QBCore:Player:SetPlayerData |
standalone |
Nothing else matched | Nothing; everyone has a phone |
qb-inventory works for every inventory that keeps items in QBCore player data (ps-inventory, lj-inventory, qs-inventory and similar). ESX without ox_inventory ends up on standalone.
#Item definitions
The item code for each inventory and the images are on Item setup.
- On ox_inventory the
phoneitem opens the phone through itsclient.event, and the SIM and power bank items report their use through thefx-phone.useSimCardserver export. - On QBCore inventories FX Phone registers
phone, the SIM items and the power bank as usable items itself.
One item per player is enough. The phone belongs to the character, not to the item.
#Items with metadata
SIM cards are items that carry data. On the server FX Phone uses ox_inventory first, then the QBCore or Qbox player inventory. Without either, physical SIMs are unavailable and only eSIMs are sold. See Owned shops.
#Another inventory
Config.Inventory = 'standalone' loads client/integrations/inventory/standalone.lua, which is open for editing. Replace its three functions with your inventory's calls:
luaIntegration.Inventory = { Name = 'my-inventory' }
function Integration.Inventory.Count(name)
return exports['my-inventory']:GetItemCount(name) or 0
end
function Integration.Inventory.HasItem(name)
return Integration.Inventory.Count(name) > 0
end
-- Call fn(hasPhone) when the player gains or loses Config.Item.
function Integration.Inventory.OnItemChanged(fn)
AddEventHandler('my-inventory:itemChanged', function(item, count)
if item == Config.Item then fn(count > 0) end
end)
end
The cylex-compatible exports getQuantity and hasEnoughOfItem use the same adapter. See cylex_phone compatibility.