Supported Inventories
🌟 Our amazing LIB!
English
Integrated Inventories
At the moment, the following inventories are integrated into bs-lib:
Since the inventory functions are Open-Source, anyone can make any script compatible by implementing it themselves!
Template
local found = GetResourceState('your_inventory')
if found ~= 'started' and found ~= 'starting' then return end
BS.inventory = {}
function BS.inventory.hasItem(item)
local inventory = exports['your_inventory']:GetClientPlayerInventory()
for _, invItem in pairs(inventory) do
if invItem.name == item then
return true
end
end
return false
end
function BS.inventory.getInventory()
return exports['your_inventory']:GetClientPlayerInventory()
end
function BS.inventory.openStash(data)
local name = data.name
if data.unique then
name = data.name .. data.citizenid
end
TriggerServerEvent('inventory:server:OpenInventory', 'stash', name, { maxweight = data.maxWeight, slots = data.slots })
TriggerEvent('inventory:client:SetCurrentStash', name)
endlocal found = GetResourceState('your_inventory')
if found ~= 'started' and found ~= 'starting' then return end
BS.inventory = {}
function BS.inventory.getItemSlot(source, itemName)
return BS.inventory.getItemSlots(source, itemName) or false
end
function BS.inventory.getItemSlots(source, itemName)
local src = source
local items = exports['your_inventory']:GetItemByName(src, itemName)
return items
end
function BS.inventory.getInventory(identifier, source)
local src = source
local inventory = exports['your_inventory']:GetInventory(identifier, src)
return inventory
end
function BS.inventory.hasItem(source, item)
local src = source
local player = BS.getPlayer(src)
if not player then return false end
local hasItem = exports['your_inventory']:HasItem(source, item)
return hasItem
end
function BS.inventory.addItem(source, itemname, amount)
local src = source
return exports['your_inventory']:AddItem(source, item, amount)
end
function BS.inventory.removeItem(source, itemname, amount)
local src = source
return exports['your_inventory']:RemoveItem(source, itemname, amount)
end
function BS.inventory.getItemMetadata(source, slot)
local player = BS.getPlayer(source)
if not player then return end
return exports['your_inventory']:GetItemBySlot(source, slot).info
end
function BS.inventory.setItemMetadata(source, slot, metadata)
if not slot then return false end
if not metadata then metadata = {} end
exports['your_inventory']:SetItemMetadata(source, slot, metadata)
endPortuguês
Inventários Integrados
De momento estão integrados na bs-lib os seguintes inventários:
Uma vez que as funções dos inventários são Open-Source, qualquer um poderá tornar compatível qualquer script fazendo tal implementação por sua conta!
Template
local found = GetResourceState('your_inventory')
if found ~= 'started' and found ~= 'starting' then return end
BS.inventory = {}
function BS.inventory.hasItem(item)
local inventory = exports['your_inventory']:GetClientPlayerInventory()
for _, invItem in pairs(inventory) do
if invItem.name == item then
return true
end
end
return false
end
function BS.inventory.getInventory()
return exports['your_inventory']:GetClientPlayerInventory()
end
function BS.inventory.openStash(data)
local name = data.name
if data.unique then
name = data.name .. data.citizenid
end
TriggerServerEvent('inventory:server:OpenInventory', 'stash', name, { maxweight = data.maxWeight, slots = data.slots })
TriggerEvent('inventory:client:SetCurrentStash', name)
endlocal found = GetResourceState('your_inventory')
if found ~= 'started' and found ~= 'starting' then return end
BS.inventory = {}
function BS.inventory.getItemSlot(source, itemName)
return BS.inventory.getItemSlots(source, itemName) or false
end
function BS.inventory.getItemSlots(source, itemName)
local src = source
local items = exports['your_inventory']:GetItemByName(src, itemName)
return items
end
function BS.inventory.getInventory(identifier, source)
local src = source
local inventory = exports['your_inventory']:GetInventory(identifier, src)
return inventory
end
function BS.inventory.hasItem(source, item)
local src = source
local player = BS.getPlayer(src)
if not player then return false end
local hasItem = exports['your_inventory']:HasItem(source, item)
return hasItem
end
function BS.inventory.addItem(source, itemname, amount)
local src = source
return exports['your_inventory']:AddItem(source, item, amount)
end
function BS.inventory.removeItem(source, itemname, amount)
local src = source
return exports['your_inventory']:RemoveItem(source, itemname, amount)
end
function BS.inventory.getItemMetadata(source, slot)
local player = BS.getPlayer(source)
if not player then return end
return exports['your_inventory']:GetItemBySlot(source, slot).info
end
function BS.inventory.setItemMetadata(source, slot, metadata)
if not slot then return false end
if not metadata then metadata = {} end
exports['your_inventory']:SetItemMetadata(source, slot, metadata)
endLast updated