Hello, I’m coding a police profession system from scratch. I’m trying to create a special ox_inventory-based store for police officers without using ox_inventory’s built-in NPC feature, but I haven’t been very successful. I’m using ox_inventory on a QBCore-based server. I tried opening it using the exports provided by ox_inventory but couldn’t make it work. I’m using ox_inventory version 2.41.0, and here’s the code I’ve written
function OpenPoliceMenu()
lib.registerContext({
id = 'antopd_police_menu',
title = 'Police Inventory',
options = {
{
title = 'Equipment Store',
icon = 'fa-solid fa-gun',
onSelect = function()
exports.ox_inventory:openInventory('shop', { type = 'PoliceArmoury', id = '2' })
end
}
}
})
lib.showContext('antopd_police_menu')
end
RegisterCommand('testshop', function()
exports.ox_inventory:openInventory('shop', { type = 'PoliceArmoury', id = 1 })
end, false)
This is the shop data I added to ox_inventory:
PoliceArmoury = {
name = 'Police Armoury',
inventory = {
{ name = 'ammo-9', price = 5 },
{ name = 'ammo-rifle', price = 5 },
{ name = 'WEAPON_FLASHLIGHT', price = 200 },
{ name = 'WEAPON_NIGHTSTICK', price = 100 },
{ name = 'WEAPON_PISTOL', price = 500, metadata = { registered = true, serial = 'POL' }, license = 'weapon' },
{ name = 'WEAPON_CARBINERIFLE', price = 1000, metadata = { registered = true, serial = 'POL' }, license = 'weapon', grade = 3 },
{ name = 'WEAPON_STUNGUN', price = 500, metadata = { registered = true, serial = 'POL' } }
},
locations = {},
targets = {}
},