πŸ“¦Custom inventory

To adapt the script to another inventory, here you can find the functions that need to be adapted

IMAGES

If your inventory already contains images for the items, you must add the path of the images in Config.ImagePath


CLIENT

if Config.Inventory == "custom" then
    InventoryFunctions = {
        -- @param stashName: string
        -- @param info: { maxweight: number, slots: number}
        OpenStash = function(stashName, info)
            TriggerServerEvent("custom-inventory:openStash", stashName, info)
        end
    }
end

SERVER

if Config.Inventory == "custom" then
    
    InventoryFunctions = {
        -- @param items: Your stash items
        -- @return { [item: string]: { amount: number, label: string, weight: number } }
        FormatItems = function(items)
            local formattedItems = {}
            for k,v in pairs(items) do 
                if formattedItems[v.name] then
                    formattedItems[v.name].amount = formattedItems[v.name].amount + v.amount
                else
                    local itemData = FrameworkFunctions.GetItemInfo(v.name)

                    formattedItems[v.name] = {
                        amount = v.amount,
                        label = itemData.label,
                        weight = itemData.weight
                    }
                end
            end

            return formattedItems
        end,

        -- @param stashName: string
        -- @return Formated items
        GetStashItems = function(stashName)
            local stashItems = exports['custom-inventory']:GetStashItems(stashName)

            return InventoryFunctions.FormatItems(stashItems)
        end,

        -- @param source: number
        -- @param item: string
        -- @return number
        GetItemTotalAmount = function(source, item)
            return exports['custom-inventory']:GetItemTotalAmount(source, item)
        end,

        -- @param source: number
        -- @param item: string
        -- @param amount: number
        GiveItemToPlayer = function(source, item, amount)
            exports['custom-inventory']:AddItem(source, item, amount)
        end,

        -- @param source: number
        -- @param item: string
        -- @param amount: number
        RemoveItem = function(source, item, amount)
            exports['custom-inventory']:RemoveItem(source, item, amount)
        end,

        -- @param stashid: string
        -- @param item: string
        -- @param amount: number
        -- @param slots: number
        -- @param maxWeight: number
        AddItemIntoStash = function(stashid, item, amount, slots, maxWeight)
            exports['custom-inventory']:AddItemIntoStash(stashid, item, amount, slots, maxWeight)
        end,

        -- @param stashName: string
        -- @param item: string
        -- @param amount: number
        -- @param slots: number
        -- @param maxWeight: number
        RemoveItemFromStash = function(stashName, item, amount, slots, maxWeight)
            exports['custom-inventory']:RemoveItemIntoStash(stashName, item, amount, slots, maxWeight)
        end,

        -- @param stashName: string
        DeleteStash = function(stashName) 
            exports['custom-inventory']:DeleteStash(stashName)
        end

    }
end

πŸ“£ Remember that you can use the other configurations already made as a guide.

Last updated