Server
inventory is a player server id, or a stash id when that inventory supports one. Item rows are { name, count, metadata, slot, label }.
ESX default items and chezza have no metadata. A call the selected inventory does not provide logs once and returns nil or false.
GetItemCount
Parameters
inventorynumber|stringitemstringmetadatatable— optional. Every listed key must match.
Returns
number
Example
local count = Bridge.GetItemCount(source, 'water', { type = 'fresh' })
if count < 1 then
return
endHasItem
Parameters
inventorynumber|stringitemstringcountnumber— optional. Defaults to1.metadatatable— optional
Returns
boolean
Example
if not Bridge.HasItem(source, 'lockpick', 1) then
Bridge.Notify(source, { description = 'You need a lockpick', kind = 'error' })
return
endAddItem
Parameters
inventorynumber|stringitemstringcountnumbermetadatatable— optional. Ignored for ESX default items and chezza.
Returns
boolean
Example
local added = Bridge.AddItem(source, 'water', 2, { type = 'fresh' })
if added then
print(Bridge.GetItemCount(source, 'water'))
endRemoveItem
Fails when the player does not hold enough.
Parameters
inventorynumber|stringitemstringcountnumbermetadatatable— optional
Returns
boolean
Example
if not Bridge.RemoveItem(source, 'water', 1) then
return
endCanCarry
Parameters
inventorynumber|stringitemstringcountnumbermetadatatable— optional
Returns
boolean
Example
if Bridge.CanCarry(source, 'water', 5) then
Bridge.AddItem(source, 'water', 5)
endCanCarryWeight
Parameters
inventorynumber|stringweightnumber
Returns
boolean
Example
if Bridge.CanCarryWeight(source, 1000) then
Bridge.AddItem(source, 'radio', 1)
endGetItemLabel
Parameters
itemstring
Returns
string — the label, or the item name when none is stored.
Example
local label = Bridge.GetItemLabel('water')
Bridge.Notify(source, { description = label, kind = 'info' })GetInventoryItems
Parameters
inventorynumber|string— player id, or a stash id when that inventory supports one
Returns
table — list of { name, count, metadata, slot, label }.
Example
local items = Bridge.GetInventoryItems(source)
for i = 1, #items do
print(items[i].slot, items[i].name, items[i].count)
endGetSlot
Parameters
inventorynumber|stringslotnumber
Returns
table|nil — { name, count, metadata, slot }.
Example
local item = Bridge.GetSlot(source, 1)
if item then
print(item.name, item.count)
endGetSlotWithItem
Parameters
inventorynumber|stringitemstringmetadatatable— optional. ESX default items and chezza have no metadata, so the match is by name.
Returns
table|nil — { name, count, metadata, slot }.
Example
local item = Bridge.GetSlotWithItem(source, 'phone')
if item then
print(item.slot, item.count)
endGetPlayerWeight
Parameters
inventorynumber|string
Returns
number
Example
local weight = Bridge.GetPlayerWeight(source)
local maxWeight = Bridge.GetPlayerMaxWeight(source)
print(weight, maxWeight)GetPlayerMaxWeight
Parameters
inventorynumber|string
Returns
number
Example
print(Bridge.GetPlayerMaxWeight(source))SetMaxWeight
Parameters
inventorynumber|stringweightnumber
Returns
boolean
Example
Bridge.SetMaxWeight(source, 30000)SetItemMetadata
Parameters
inventorynumber|stringslotnumbermetadatatable
Returns
boolean — false for ESX default items and chezza, which have no metadata.
Example
Bridge.SetItemMetadata(source, 1, { durability = 50, serial = 'A12' })SetDurability
Parameters
inventorynumber|stringslotnumberdurabilitynumber
Returns
boolean
Example
Bridge.SetDurability(source, 1, 100)ClearInventory
Parameters
inventorynumber|stringkeepstring|string[]— optional item names to leave behind. Inventories that have no keep list clear everything.
Returns
boolean
Example
Bridge.ClearInventory(source, { 'phone', 'id_card' })RegisterStash
Parameters
idstringlabelstringslotsnumbermaxWeightnumberownerboolean|string— optionalgroupstable— optional, such as{ police = 0 }coordsvector3— optional
Returns
boolean
Example
Bridge.RegisterStash('police_locker', 'Locker', 50, 100000, true, { police = 0 })ForceOpenInventory
Opens an inventory for a player without the usual distance check.
Parameters
playerIdnumber— who sees the inventorykindstring—stash,player,glovebox, ortrunkdatastring|number|table— stash id, target server id, or{ id, owner, label }
Returns
boolean
Example
Bridge.ForceOpenInventory(source, 'stash', 'society_police')
Bridge.ForceOpenInventory(source, 'player', target)CloseInventory
Closes the inventory UI for that player.
Parameters
playerIdnumber
Returns
boolean
Example
Bridge.CloseInventory(source)RegisterUsableItem
The handler runs on the server when the player uses the item. It only fires for items that inventory already treats as usable.
Parameters
itemstringhandlerfunction—handler(source, item)whereitemis{ name, count, metadata, slot }
Returns
boolean
Example
Bridge.RegisterUsableItem('radio', function(playerId, item)
print(playerId, item.name, item.slot)
end)