Migrating from ox_inventory
Scripts written for ox_inventory keep working: the inventory answers exports.ox_inventory calls with the same names and arguments, fires the ox events, and imports your ox data at start.
-
Turn the ox_inventory folder into the bridge
Stop ox_inventory. Delete everything in theox_inventoryfolder exceptdata/, then copybridge/ox_inventory/fxmanifest.luafrom koja-inventory-v2 into it. The folder keeps theox_inventoryname, sodependency 'ox_inventory'in other resources and ESX's ox mode keep working, and it serves your olddata/*.luafiles. -
Update server.cfg
The bridge must start after the inventory.server.cfgensure koja-inventory-v2 ensure ox_inventory -
Start the server
Your ox items, weapons, ammo, attachments, shops, stashes and crafting benches are imported fromdata/(Config.Ox.importItems,importShops,importStashes,importCrafting). The console banner shows how many items came from ox. Grid sizes for imported items are guessed: by weight for normal items (up to 250 g is 1x1, up to 1 kg 1x2, up to 3 kg 2x2, heavier 3x2) and by weapon type for weapons (rifles 4x2, snipers and launchers 5x2, shotguns 5x1, SMGs 3x2, pistols 2x2, long melee 1x3). To change a size, define the item inshared/items.lua. -
Players
Each player's ox inventory is imported the first time they join (fromusers.inventoryon ESX orplayers.inventoryon QBCore), whenConfig.Ox.migratePlayersis on. To move everything at once, including offline players, stashes, trunks and gloveboxes, run this in the server console:koja_migrate_oxkoja_migrate_ox forceoverwrites inventories that were already imported. Items that do not fit the new grid are kept and placed as soon as there is room.
What stays compatible
- Server exports:
Items,AddItem,RemoveItem,GetItem,GetItemCount,Search,GetSlot,GetSlotWithItem,GetSlotsWithItem,GetSlotIdWithItem,GetSlotIdsWithItem,GetItemSlots,GetSlotForItem,GetEmptySlot,GetInventory,GetInventoryItems,GetContainerFromSlot,CanCarryItem,CanCarryAmount,CanCarryWeight,CanSwapItem,SetItem,SetMetadata,SetDurability,SetMaxWeight,ClearInventory,RegisterStash,CreateTemporaryStash,CustomDrop,forceOpenInventory,InspectInventory,RegisterShop,ConfiscateInventory,ReturnInventory,GetCurrentWeapon,UpdateVehicle,registerHook,removeHooks,setPlayerInventory. - Client exports:
openInventory,closeInventory,openNearbyInventory,Items,Search,GetItemCount,GetPlayerItems,GetPlayerWeight,GetPlayerMaxWeight,GetSlotWithItem,GetSlotsWithItem,GetSlotIdWithItem,GetSlotIdsWithItem,getCurrentWeapon,useSlot,useItem,giveItemToTarget,weaponWheel. - Events:
ox_inventory:usedItem,ox_inventory:openedInventory,ox_inventory:closedInventoryon the server,ox_inventory:currentWeaponon the client, state bagsinvOpenandinvBusy. - Hooks:
swapItems,openInventory,usingItemandcreateItemwithitemFilterandinventoryFilter. - Usable items: ox
client.export/server.exporton the item definition. - ESX: with the bridge, ESX runs in ox mode, so
xPlayer.addInventoryItem,removeInventoryItem,getInventoryItem,canCarryItem,getInventory()and account money use this inventory.
Slots are stable numbers per inventory, so a slot from GetSlotWithItem can be passed back to RemoveItem or SetMetadata. The inv argument accepts a player id, a stash name, { id = name, owner = identifier }, 'trunk' .. plate, 'glove' .. plate or a container id like stash:name.
See the Developer API for the extra exports this inventory adds.