Logo

DIVERSITY

Documentation

Modules

Inventory

The Inventory module provides a unified interface for handling player inventory items across different inventory systems.

Warning

The "Built-in Framework" inventory support (e.g. relying on dBridge.Inventory without an external inventory system) is only compatible with ESX and QBCore. Frameworks like ox_core, nd_core, QBox, and TMC do not provide built-in inventory functions and require a supported external inventory system (e.g. ox_inventory) to be installed and running.

Client Functions


GetResourceName

Returns the name of the underlying inventory resource being used.

client.lua
local resourceName = dBridge.Inventory.GetResourceName()
Returned DataTypeDescription
resourceName
string
The name of the inventory resource (e.g., "ox_inventory").

GetItemCount

Returns the count of a specific item.

client.lua
local count = dBridge.Inventory.GetItemCount('water')
ArgumentTypeDescription
itemName
string
Name of the item.
metadata?
table
Item metadata (optional).
strict?
boolean
Strict matching (optional).
Returned DataTypeDescription
count
number
Count of the item.

HasItem

Checks if the player has a specific item.

client.lua
local hasItem = dBridge.Inventory.HasItem('water', 1)
ArgumentTypeDescription
itemName
string
Name of the item.
requiredCount?
number
Quantity required (optional).
Returned DataTypeDescription
hasItem
boolean
True if player has the item.

GetPlayerInventory

Returns the player's full inventory.

client.lua
local inventory = dBridge.Inventory.GetPlayerInventory()
Returned DataTypeDescription
inventory
table
The inventory table.

GetImagePath

Returns an image path for an item.

client.lua
local image = dBridge.Inventory.GetImagePath(itemName)
ArgumentTypeDescription
itemName
string
Name of the item.
Returned DataTypeDescription
items
string
The image path.

Server Functions


GetResourceName

Returns the name of the underlying inventory resource being used.

server.lua
local resourceName = dBridge.Inventory.GetResourceName()
Returned DataTypeDescription
resourceName
string
The name of the inventory resource (e.g., "ox_inventory").

AddItem

Adds an item to the player's inventory.

server.lua
local success = dBridge.Inventory.AddItem(source, 'water', 1)
ArgumentTypeDescription
source
number
The player ID (source).
itemName
string
Name of the item.
itemCount
number
Quantity to add.
metadata?
table
Item metadata (optional).
slot?
number
Specific slot (optional).
Returned DataTypeDescription
success
boolean
Whether the operation was successful.

RemoveItem

Removes an item from the player's inventory.

server.lua
local success = dBridge.Inventory.RemoveItem(source, 'water', 1)
ArgumentTypeDescription
source
number
The player ID (source).
itemName
string
Name of the item.
itemCount
number
Quantity to remove.
metadata?
table
Item metadata (optional).
slot?
number
Specific slot (optional).
Returned DataTypeDescription
success
boolean
Whether the operation was successful.

CanCarryItem

Checks if the player can carry an item.

server.lua
local canCarry = dBridge.Inventory.CanCarryItem(source, 'water', 1)
ArgumentTypeDescription
source
number
The player ID (source).
itemName
string
Name of the item.
itemCount
number
Quantity to check.
metadata?
table
Item metadata (optional).
Returned DataTypeDescription
canCarry
boolean
True if player can carry the item.
This function is not supported on ps-inventory (always returns true).

GetItemCount

Returns the count of a specific item.

server.lua
local count = dBridge.Inventory.GetItemCount(source, 'water')
ArgumentTypeDescription
source
number
The player ID (source).
itemName
string
Name of the item.
metadata?
table
Item metadata (optional).
Returned DataTypeDescription
count
number
Count of the item.

HasItem

Checks if the player has a specific item.

server.lua
local hasItem = dBridge.Inventory.HasItem(source, 'water', 1)
ArgumentTypeDescription
source
number
The player ID (source).
itemName
string
Name of the item.
itemCount
number
Quantity required.
metadata?
table
Item metadata (optional).
Returned DataTypeDescription
hasItem
boolean
True if player has the item.

GetItemByName

Returns item data by name.

server.lua
local item = dBridge.Inventory.GetItemByName(source, 'water')
ArgumentTypeDescription
source
number
The player ID (source).
itemName
string
Name of the item.
metadata?
table
Item metadata (optional).
Returned DataTypeDescription
item
table
The item data.

GetItemBySlot

Returns item data by slot.

server.lua
local item = dBridge.Inventory.GetItemBySlot(source, 1)
ArgumentTypeDescription
source
number
The player ID (source).
slot
number
Slot number.
metadata?
table
Item metadata (optional).
Returned DataTypeDescription
item
table
The item data.

GetPlayerInventory

Returns the player's full inventory.

server.lua
local inventory = dBridge.Inventory.GetPlayerInventory(source)
ArgumentTypeDescription
source
number
The player ID (source).
Returned DataTypeDescription
inventory
table
The inventory table.

ClearPlayerInventory

Clears the player's inventory.

server.lua
dBridge.Inventory.ClearPlayerInventory(source)
ArgumentTypeDescription
source
number
The player ID (source).
This function is not supported on ps-inventory.

SetMetadata

Sets metadata for an item in a specific slot.

server.lua
dBridge.Inventory.SetMetadata(source, 1, {quality = 100})
ArgumentTypeDescription
source
number
The player ID (source).
slot
number
The slot number.
metadata
table
The metadata table.
This function is not supported on qb-inventory, ps-inventory, or built-in ESX inventory.

RegisterStash

Registers a stash.

server.lua
dBridge.Inventory.RegisterStash('my_stash', 'My Stash', 50, 100000)
ArgumentTypeDescription
stashId
string | number
Unique stash ID.
label
string
Stash label.
slots
number
Number of slots.
maxWeight
number
Max weight.
owner?
string | boolean
Owner identifier (optional).
groups?
string[]
Allowed groups (optional).
coords?
vector3
Stash coordinates (optional).
This function is not supported on ps-inventory, qs-inventory, or built-in framework inventories (ESX/QBCore).

OpenStash

Opens a registered stash for a player.

server.lua
dBridge.Inventory.OpenStash(source, 'stash', 'my_stash')
ArgumentTypeDescription
source
number
The player ID (source).
type?
string
Stash type (stash, trunk, glovebox).
stashId
string | number
Stash ID.
This function is not supported on built-in framework inventories (ESX/QBCore).

AddStashItems

Adds items to a stash.

server.lua
dBridge.Inventory.AddStashItems('my_stash', {{item = 'water', count = 1}})
ArgumentTypeDescription
stashId
string | number
Stash ID.
items
table[]
List of items to add.
This function is not supported on ps-inventory, qs-inventory, or built-in framework inventories (ESX/QBCore).

GetStashItems

Returns items from a stash.

server.lua
local items = dBridge.Inventory.GetStashItems('my_stash')
ArgumentTypeDescription
stashId
string | number
Stash ID.
Returned DataTypeDescription
items
table
List of items.
This function is not supported on ps-inventory, qs-inventory, or built-in framework inventories (ESX/QBCore).

ClearStash

Clears a stash.

server.lua
dBridge.Inventory.ClearStash('my_stash')
ArgumentTypeDescription
stashId
string | number
Stash ID.
type?
string
Stash type (optional).
This function is not supported on ps-inventory, qs-inventory, or built-in framework inventories (ESX/QBCore).

GetItemLabel

Returns the label of an item.

server.lua
local label = dBridge.Inventory.GetItemLabel('water')
ArgumentTypeDescription
itemName
string
Name of the item.
Returned DataTypeDescription
label
string
The item label.

Items

Returns a list of all items or a specific item definition.

server.lua
local items = dBridge.Inventory.Items()
ArgumentTypeDescription
itemName?
string
Name of the item (optional).
Returned DataTypeDescription
items
table
The items table.
This function is not supported on qb-inventory.

GetImagePath

Returns an image path for an item.

server.lua
local image = dBridge.Inventory.GetImagePath(itemName)
ArgumentTypeDescription
itemName
string
Name of the item.
Returned DataTypeDescription
items
string
The image path.

Was this page helpful?