Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
20 changes: 12 additions & 8 deletions bridge/inventory/qb/server/qb.lua
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,6 @@ function ps.removeItem(identifier, item, amount, slot, reason)
return false
end


-- @param identifier number|string i.e. source or CitizenID
-- @param item string
-- @param amount number
Expand All @@ -27,7 +26,7 @@ end
-- @param reason string ** optional
-- @return boolean
-- example: ps.addItem(source, 'bread', 1, {quality = 100}, false, 'ps_lib Add Item')
function ps.addItem(identifier, item, amount,meta, slot, reason)
function ps.addItem(identifier, item, amount, meta, slot, reason)
if not identifier or not item then return end
if not amount then amount = 1 end
if not slot then slot = false end
Expand All @@ -39,7 +38,6 @@ function ps.addItem(identifier, item, amount,meta, slot, reason)
return false
end


-- @param source number|string i.e. source or CitizenID
-- @param identifier string i.e. stash name
-- @param data table i.e. {label = 'Stash', maxweight = 100000, slots = 50} ** optional
Expand Down Expand Up @@ -92,7 +90,6 @@ function ps.clearStash(source, identifier)
exports['qb-inventory']:ClearStash(source, identifier)
end


-- @param identifier number|string i.e. source
-- @param item string
-- @return number
Expand Down Expand Up @@ -136,15 +133,22 @@ function ps.createShop(source, shopData)
if not shopData.items then shopData.items = {} end
if not shopData.slots then shopData.slots = #shopData.items end
if not shopData.label then shopData.label = shopData.name end
exports['qb-inventory']:CreateShop(source, shopData.name, shopData.items)

exports['qb-inventory']:CreateShop({
name = shopData.name,
label = shopData.label,
slots = shopData.slots,
items = shopData.items
})

exports['qb-inventory']:OpenShop(source, shopData.name)
end

-- @param source number|string i.e. source
-- @param recipe table i.e. {take = {bread = 1, water = 1}, give = {sandwich = 1}}
function ps.verifyRecipe(source, recipe)
local need, have = 0,0
for k, v in pairs (recipe) do
local need, have = 0, 0
for k, v in pairs(recipe) do
if ps.getItemCount(source, k) >= v then
have = have + 1
end
Expand Down Expand Up @@ -189,4 +193,4 @@ exports('getItemByName', ps.getItemByName)
exports('getItemsByNames', ps.getItemsByNames)
exports('createShop', ps.createShop)
exports('verifyRecipe', ps.verifyRecipe)
exports('craftItem', ps.craftItem)
exports('craftItem', ps.craftItem)