Skip to main content

Quick References

Opening vehicle storage​

The configured inventory key (default F2) closes an already-open inventory. Otherwise it checks nearby drops, then shops, then vehicle storage before falling back to the player's inventory. Inside an eligible vehicle it opens the glovebox; on foot near an accessible trunk it opens the trunk. Vehicle model rules, capacities, lock state, and access checks can prevent opening.

Scripted integrations can use openInventory('trunk', { netId = vehicleNetId }) or openInventory('glovebox', { netId = vehicleNetId }). Use a vehicle network ID, not a local entity handle. See Exports and Vehicle storage definitions.

Common wasabi_inventory integration patterns.

Check and remove an item safely​

local source = 12
local count = exports.wasabi_inventory:GetItemCount(source, 'lockpick')

if count >= 1 then
local removed, reason = exports.wasabi_inventory:RemoveItem(source, 'lockpick', 1)
if not removed then
print(('Remove failed: %s'):format(reason or 'unknown'))
end
end

Check capacity before giving a reward​

local canCarry = exports.wasabi_inventory:CanCarryItem(source, 'gold_bar', 1)
if canCarry then
local added, reason = exports.wasabi_inventory:AddItem(source, 'gold_bar', 1, {
origin = 'mission_reward',
})
end

Open a personal locker​

-- Server startup
exports.wasabi_inventory:RegisterStash(
'personal_locker',
'Personal Locker',
40,
100000,
true
)
-- Client interaction
exports.wasabi_inventory:openInventory('stash', { id = 'personal_locker' })

Register and open a scripted shop​

-- Server
exports.wasabi_inventory:RegisterShop('MissionShop', {
name = 'Mission Shop',
inventory = {
{ name = 'water', price = 5 },
{ name = 'radio', price = 250 },
},
})
-- Client
exports.wasabi_inventory:openInventory('shop', { type = 'MissionShop' })

Add serial metadata​

local added = exports.wasabi_inventory:AddItem(source, 'WEAPON_PISTOL', 1, {
serial = ('WS-%06d'):format(math.random(0, 999999)),
registered = true,
})

Cancel restricted transfers​

local hookId = exports.wasabi_inventory:registerHook('swapItems', function(payload)
if payload.toInventory == 'evidence_archive' then
return false
end
end, {
inventoryFilter = { '^evidence_archive$' },
})

Listen for local item count changes​

AddEventHandler('wasabi_inventory:itemCount', function(itemName, count)
if itemName == 'radio' then
print(('Radio count: %s'):format(count))
end
end)

Compatibility usage​

For integrations already using a supported ox_inventory export, the resource also exposes aliases through the ox_inventory namespace:

local count = exports.ox_inventory:GetItemCount(source, 'water')

Prefer exports.wasabi_inventory in new Wasabi-native integrations.