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.
local resourceName = dBridge.Inventory.GetResourceName()| Returned Data | Type | Description |
|---|---|---|
resourceName | string | The name of the inventory resource (e.g., "ox_inventory"). |
GetItemCount
Returns the count of a specific item.
local count = dBridge.Inventory.GetItemCount('water')| Argument | Type | Description |
|---|---|---|
itemName | string | Name of the item. |
metadata? | table | Item metadata (optional). |
strict? | boolean | Strict matching (optional). |
| Returned Data | Type | Description |
|---|---|---|
count | number | Count of the item. |
HasItem
Checks if the player has a specific item.
local hasItem = dBridge.Inventory.HasItem('water', 1)| Argument | Type | Description |
|---|---|---|
itemName | string | Name of the item. |
requiredCount? | number | Quantity required (optional). |
| Returned Data | Type | Description |
|---|---|---|
hasItem | boolean | True if player has the item. |
GetPlayerInventory
Returns the player's full inventory.
local inventory = dBridge.Inventory.GetPlayerInventory()| Returned Data | Type | Description |
|---|---|---|
inventory | table | The inventory table. |
GetImagePath
Returns an image path for an item.
local image = dBridge.Inventory.GetImagePath(itemName)| Argument | Type | Description |
|---|---|---|
itemName | string | Name of the item. |
| Returned Data | Type | Description |
|---|---|---|
items | string | The image path. |
Server Functions
GetResourceName
Returns the name of the underlying inventory resource being used.
local resourceName = dBridge.Inventory.GetResourceName()| Returned Data | Type | Description |
|---|---|---|
resourceName | string | The name of the inventory resource (e.g., "ox_inventory"). |
AddItem
Adds an item to the player's inventory.
local success = dBridge.Inventory.AddItem(source, 'water', 1)| Argument | Type | Description |
|---|---|---|
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 Data | Type | Description |
|---|---|---|
success | boolean | Whether the operation was successful. |
RemoveItem
Removes an item from the player's inventory.
local success = dBridge.Inventory.RemoveItem(source, 'water', 1)| Argument | Type | Description |
|---|---|---|
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 Data | Type | Description |
|---|---|---|
success | boolean | Whether the operation was successful. |
CanCarryItem
Checks if the player can carry an item.
local canCarry = dBridge.Inventory.CanCarryItem(source, 'water', 1)| Argument | Type | Description |
|---|---|---|
source | number | The player ID (source). |
itemName | string | Name of the item. |
itemCount | number | Quantity to check. |
metadata? | table | Item metadata (optional). |
| Returned Data | Type | Description |
|---|---|---|
canCarry | boolean | True if player can carry the item. |
GetItemCount
Returns the count of a specific item.
local count = dBridge.Inventory.GetItemCount(source, 'water')| Argument | Type | Description |
|---|---|---|
source | number | The player ID (source). |
itemName | string | Name of the item. |
metadata? | table | Item metadata (optional). |
| Returned Data | Type | Description |
|---|---|---|
count | number | Count of the item. |
HasItem
Checks if the player has a specific item.
local hasItem = dBridge.Inventory.HasItem(source, 'water', 1)| Argument | Type | Description |
|---|---|---|
source | number | The player ID (source). |
itemName | string | Name of the item. |
itemCount | number | Quantity required. |
metadata? | table | Item metadata (optional). |
| Returned Data | Type | Description |
|---|---|---|
hasItem | boolean | True if player has the item. |
GetItemByName
Returns item data by name.
local item = dBridge.Inventory.GetItemByName(source, 'water')| Argument | Type | Description |
|---|---|---|
source | number | The player ID (source). |
itemName | string | Name of the item. |
metadata? | table | Item metadata (optional). |
| Returned Data | Type | Description |
|---|---|---|
item | table | The item data. |
GetItemBySlot
Returns item data by slot.
local item = dBridge.Inventory.GetItemBySlot(source, 1)| Argument | Type | Description |
|---|---|---|
source | number | The player ID (source). |
slot | number | Slot number. |
metadata? | table | Item metadata (optional). |
| Returned Data | Type | Description |
|---|---|---|
item | table | The item data. |
GetPlayerInventory
Returns the player's full inventory.
local inventory = dBridge.Inventory.GetPlayerInventory(source)| Argument | Type | Description |
|---|---|---|
source | number | The player ID (source). |
| Returned Data | Type | Description |
|---|---|---|
inventory | table | The inventory table. |
ClearPlayerInventory
Clears the player's inventory.
dBridge.Inventory.ClearPlayerInventory(source)| Argument | Type | Description |
|---|---|---|
source | number | The player ID (source). |
SetMetadata
Sets metadata for an item in a specific slot.
dBridge.Inventory.SetMetadata(source, 1, {quality = 100})| Argument | Type | Description |
|---|---|---|
source | number | The player ID (source). |
slot | number | The slot number. |
metadata | table | The metadata table. |
RegisterStash
Registers a stash.
dBridge.Inventory.RegisterStash('my_stash', 'My Stash', 50, 100000)| Argument | Type | Description |
|---|---|---|
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). |
OpenStash
Opens a registered stash for a player.
dBridge.Inventory.OpenStash(source, 'stash', 'my_stash')| Argument | Type | Description |
|---|---|---|
source | number | The player ID (source). |
type? | string | Stash type (stash, trunk, glovebox). |
stashId | string | number | Stash ID. |
AddStashItems
Adds items to a stash.
dBridge.Inventory.AddStashItems('my_stash', {{item = 'water', count = 1}})| Argument | Type | Description |
|---|---|---|
stashId | string | number | Stash ID. |
items | table[] | List of items to add. |
GetStashItems
Returns items from a stash.
local items = dBridge.Inventory.GetStashItems('my_stash')| Argument | Type | Description |
|---|---|---|
stashId | string | number | Stash ID. |
| Returned Data | Type | Description |
|---|---|---|
items | table | List of items. |
ClearStash
Clears a stash.
dBridge.Inventory.ClearStash('my_stash')| Argument | Type | Description |
|---|---|---|
stashId | string | number | Stash ID. |
type? | string | Stash type (optional). |
GetItemLabel
Returns the label of an item.
local label = dBridge.Inventory.GetItemLabel('water')| Argument | Type | Description |
|---|---|---|
itemName | string | Name of the item. |
| Returned Data | Type | Description |
|---|---|---|
label | string | The item label. |
Items
Returns a list of all items or a specific item definition.
local items = dBridge.Inventory.Items()| Argument | Type | Description |
|---|---|---|
itemName? | string | Name of the item (optional). |
| Returned Data | Type | Description |
|---|---|---|
items | table | The items table. |
GetImagePath
Returns an image path for an item.
local image = dBridge.Inventory.GetImagePath(itemName)| Argument | Type | Description |
|---|---|---|
itemName | string | Name of the item. |
| Returned Data | Type | Description |
|---|---|---|
items | string | The image path. |