HasItem + partial support for shops
This commit is contained in:
1 parent
f28e511de6
commit
dee14600ba
14 files changed
+220
-7
No files matched your search
@@ -41,6 +41,14 @@ Inventory.GetImagePath = function(item)
|
||||
return imagePath or "https://avatars.githubusercontent.com/u/47620135"
|
||||
end
|
||||
|
||||
---comment
|
||||
---@param src number
|
||||
---@param item string
|
||||
---@return boolean
|
||||
Inventory.HasItem = function(src, item)
|
||||
return sloth:HasItem(src, item, 1)
|
||||
end
|
||||
|
||||
---comment
|
||||
---@param src number
|
||||
---@param slot number
|
||||
@@ -61,7 +69,7 @@ end
|
||||
Inventory.AddItem = function(src, item, amount, slot, metadata)
|
||||
TriggerClientEvent('ps-inventory:client:ItemBox', src, QBCore.Shared.Items[item], 'add')
|
||||
TriggerClientEvent("community_bridge:client:inventory:updateInventory", src, {action = "add", item = item, count = amount, slot = slot, metadata = metadata})
|
||||
return exports['ps-inventory']:AddItem(src, item, amount, slot, metadata, 'community_bridge')
|
||||
return sloth:AddItem(src, item, amount, slot, metadata, 'community_bridge')
|
||||
end
|
||||
|
||||
|
||||
@@ -75,7 +83,7 @@ end
|
||||
Inventory.RemoveItem = function(src, item, amount, slot, metadata)
|
||||
TriggerClientEvent('ps-inventory:client:ItemBox', src, QBCore.Shared.Items[item], 'remove')
|
||||
TriggerClientEvent("community_bridge:client:inventory:updateInventory", src, {action = "remove", item = item, count = amount, slot = slot, metadata = metadata})
|
||||
return exports['ps-inventory']:RemoveItem(src, item, amount, slot, 'community_bridge')
|
||||
return sloth:RemoveItem(src, item, amount, slot, 'community_bridge')
|
||||
end
|
||||
|
||||
|
||||
@@ -93,4 +101,26 @@ Inventory.UpdatePlate = function(oldplate, newplate)
|
||||
if GetResourceState('jg-mechanic') ~= 'started' then return true end
|
||||
exports["jg-mechanic"]:vehiclePlateUpdated(oldplate, newplate)
|
||||
return true
|
||||
end
|
||||
|
||||
local registeredShops = {}
|
||||
|
||||
Inventory.OpenShop = function(src, shopTitle)
|
||||
return sloth:OpenShop(src, shopTitle)
|
||||
end
|
||||
|
||||
Inventory.CreateShop = function(src, shopTitle, shopInventory, shopCoords, shopGroups)
|
||||
if not shopTitle or not shopInventory or not shopCoords then return end
|
||||
if registeredShops[shopTitle] then return true end
|
||||
|
||||
local repackItems = {}
|
||||
local repackedShopItems = {name = shopTitle, label = shopTitle, coords = shopCoords, items = repackItems, slots = #shopInventory, }
|
||||
for k, v in pairs(shopInventory) do
|
||||
table.insert(repackItems, { name = v.name, price = v.price or 1000, amount = v.count or 1, slot = k })
|
||||
end
|
||||
|
||||
sloth:CreateShop(repackedShopItems)
|
||||
registeredShops[shopTitle] = true
|
||||
--Inventory.OpenShop(src, shopTitle)
|
||||
return true
|
||||
end
|
||||
Reference in new issue
Block a user