Inventory
Migration
QBCore, Qbox, ESX, OX
Framework and Script Migration
TSS Bridge selects the framework adapter. Existing framework inventory functions and direct calls to another inventory may still need changing.
Existing item data is not imported automatically.
Start order
Example for QBCore:
setr tss_framework qb
setr tss_inventory tss
ensure oxmysql
ensure qb-core
ensure tss_bridge
ensure tss-inventory
For other frameworks:
| Framework | tss_framework | Resource |
|---|---|---|
| QBCore | qb | qb-core |
| Qbox | qbox | qbx_core |
| ESX | esx | es_extended |
Stop the inventory you are replacing. Start item-effect scripts after tss-inventory.
QBCore: HasItem
In qb-core/client/functions.lua, replace QBCore.Functions.HasItem:
function QBCore.Functions.HasItem(items, amount)
if GetResourceState('tss-inventory') ~= 'started' then
return false
end
return exports['tss-inventory']:HasItem(items, amount)
end
In qb-core/server/functions.lua:
function QBCore.Functions.HasItem(playerSource, items, amount)
if GetResourceState('tss-inventory') ~= 'started' then
return false
end
return exports['tss-inventory']:HasItem(playerSource, items, amount)
end
Checks accept an item name, a list, or named amounts:
exports['tss-inventory']:HasItems(playerSource, {
bandage = 2,
water_bottle = 1,
})
Player checks include the main inventory and enabled extra slots. They do not search inside nested containers.
Use server checks before granting rewards or applying effects.
QBCore: usable items
In qb-core/server/functions.lua:
function QBCore.Functions.CreateUseableItem(itemName, callback)
QBCore.UsableItems[itemName] = callback
return exports['tss-inventory']:CreateUsableItem(
itemName,
callback,
GetInvokingResource()
)
end
function QBCore.Functions.CanUseItem(itemName)
return exports['tss-inventory']:GetUsableItem(itemName)
end
function QBCore.Functions.UseItem(playerSource, item)
return exports['tss-inventory']:UseItem(playerSource, item)
end
Callbacks receive slot and info alongside id and metadata.
Remove consumed items once, on the server. Keep deprecated client-callable QBCore AddItem/RemoveItem events disabled.
QBCore: player item methods
In qb-core/server/player.lua, add or replace these methods inside QBCore.Player.CreatePlayer, alongside the other self.Functions methods:
function self.Functions.AddItem(itemName, amount, slot, info, reason)
return exports['tss-inventory']:AddItem(
self.PlayerData.source,
itemName,
amount or 1,
slot,
info,
reason
)
end
function self.Functions.RemoveItem(itemName, amount, slot, reason)
return exports['tss-inventory']:RemoveItem(
self.PlayerData.source,
itemName,
amount or 1,
slot,
reason
)
end
function self.Functions.GetItemByName(itemName)
return exports['tss-inventory']:GetItemByName(
self.PlayerData.source,
itemName
)
end
function self.Functions.GetItemBySlot(slot)
return exports['tss-inventory']:GetItemBySlot(
self.PlayerData.source,
slot
)
end
These methods are for online players.
Pass false or nil for automatic placement. A supplied slot identifies an existing item stack, not an empty grid cell.
Skip the old qb-inventory LoadInventory/SaveInventory calls when using TSS. TSS manages its own loading and saving.
Replace scripts reading PlayerData.items directly with the item getter exports.
Moving scripts from qb-inventory
For supported functions, replace:
exports['qb-inventory']
with:
exports['tss-inventory']
Check the Server Exports and Client Exports pages before replacing calls.
Important differences:
- Item IDs and slots identify stacks, not grid cells.
- Use
MoveItemfor grid coordinates. GetSlotscounts occupied and free cells.- Shops require coordinates.
LoadInventory,SaveInventory,SetInventory,RemoveInventory,OpenInventoryByIdand QB hook/listener calls are not direct replacements.
Qbox
Set:
setr tss_framework qbox
setr tss_inventory tss
Replace inventory calls in your scripts with the matching TSS exports.
Before removing ox_inventory, check qbx_core/server/player.lua and Qbox's QB bridge files for remaining inventory and money calls.
Selecting the bridge adapter does not automatically replace those core calls.
ESX
Set:
setr tss_framework esx
setr tss_inventory tss
Replace script item checks, additions and removals with TSS exports using the player's server ID:
local inventory = exports['tss-inventory']
inventory:HasItem(playerSource, 'bandage', 1)
inventory:AddItem(playerSource, 'bandage', 1)
inventory:RemoveItem(playerSource, 'bandage', 1)
Register item effects with CreateUsableItem.
To keep existing ESX scripts unchanged, edit the corresponding xPlayer item methods to forward to TSS.
Selecting the bridge adapter does not redirect ESX's saved inventory or item methods automatically.
Register an item effect directly
Define the item in data/items.lua, then register its effect in a server script:
exports['tss-inventory']:CreateUsableItem('bandage', function(playerSource, item, inventoryId)
local removed = exports['tss-inventory']:RemoveItem(
inventoryId,
item.id,
1
)
if not removed then
return
end
-- Apply the effect here.
end)
Use the callback's inventoryId when consuming the selected item. This also handles items used from carried containers.
Restart the registering script after restarting tss-inventory.
Test the migration
- Add an item.
- Check it with the server HasItem export.
- Use it and confirm it is consumed once.
- Move it between inventories.
- Reconnect and confirm it saved.
- Test your connected scripts.
Keep the old inventory tables until any item-data conversion is complete.