PS-Inventory snippets
There are only two functions for inventories. You can find them in server/inventory/*.lua its different for many inventories.
These functions above is for ps-inventory:
One of them is giveItem function:
--- @param src number
--- @param type string
--- @param count number
function giveItem(src, item, count)
exports['ps-inventory']:AddItem(src, item, count)
notify.send(src, string.format(Locales.Get("GOT_ITEM"), count, item), 2500)
end
And the second one is canCarry function:
--- @param src number
--- @param type string
--- @param count number
function canCarry(src, item, count)
local Player = QBCore.Functions.GetPlayer(src)
local totalWeight = exports['ps-inventory']:GetTotalWeight(Player.PlayerData.items)
local itemInfo = QBCore.Shared.Items[item:lower()]
if totalWeight + (itemInfo['weight'] * count) <= Config.MaxInventoryWeight then
return true
else
notify.send(src, Locales.Get('NOT_E_SPACE'), 'info', 2500)
end
end
Also add new value into config.lua for this case:
Config.MaxInventoryWeight = 120000 -- written in grams (120000g == 120kg)
Make new file in server/inventory/[name-of-inventory].lua
Add new enum for your inv in shared/enum.lua Just like that: Inventory = { OXInventory = 1, QBInventory = 2, ESXInventory = 3, [YOUR-INVENTORY] = 4 }
And thats it, only you need to do is change number to yours Config.InventorySystem = 4
if Config.InventorySystem == Inventory.[YOUR-INVENTORY] then
-- Here you can insert these two functions
end
Last updated