Page cover

🔩Basics

Hello, this docs its teaching basics of inventory!

Custom Inventory Creation

Locate "config_items.lua" inside inventory folder,

  ["inventory_item_name"] = {    -- Our custom inventory
        ["item"] = {
            _id = "inventory_item_name",
            _name = "NotImportant",
            _parent = "",
            _type = "Node",
            _data = {
                Name = "Inventory Name",
                Label = "Inventory Label",
                Description = "",
                Width = 1,
                Height = 1,
                Weight = 1.5,
                ExamineTime = 3.0,
                Backgroundcolor = "black",
                ItemSound = "gear_generic",
                Type = "container",
                MaxStack = 1,
                Grids = {
                    [0] = {
                        _name ="1",
                        _id ="Not_Important",
                        _parent ="inventory_item_name",
                        cellsH = 9, -- Our cells width
                        cellsV = 3, -- Our grids width
                    },
                },
                Itemimage = "",
            }
        }
    },

Before creating the inventory, you need to trigger the custom inventory with export. You can use example export for example inventory,

exports["ls-inventoryhud"]:CustomInventory(ourinventoryid, inventory_item_name, isTemporary)

What is mean this variables?

  • ourinventoryid Is means Inventory name in database like "motel-george"

  • inventory_item_name It's a created item in config_items

  • isTemporary If is true never will be saved

Inventory Item Creation

Locate "config_items.lua" inside inventory folder,

  ["pasta"] = {    -- Our custom item
        ["item"] = {
            _id = "pasta", -- Item code example, /giveitem 1 pasta
            _name = "Pasta", -- Item name
            _parent = "", -- Item parent make empty, it will adjust itself
            _type = "Item", -- Item type if not an custom object make Item
            _data = { -- Data
                Name = "Pasta", -- Item name, its listed in JavaScript
                Label = "Pasta La Wista", -- Item label
                Description = "Its so delicous!", -- Item description, you can see from tooltip
                Width = 1, -- Item width (1-x)
                Height = 1, -- Item height (x-1)
                Weight = 0.5, -- Item weight
                ExamineTime = 1.0, -- Item research speed
                Backgroundcolor = "black", -- Item background color
                ItemSound = "gear_generic", -- Item sound
                Type = "Item", -- Item type, same as upper
                MaxStack = 1, -- Item stack limit
                Grids = {}, -- If not container make empty
                Itemimage = "icons/pasta.png", -- Item image
            }
        }
    },

After the creating the item, restart the server. If doesn't want to restart everytime locate config.lua and find Config.Debug = false, make it true. You can restart inventory everytime.

Item Convert! (QB-ESX)

Start your server, enter the "convertitems" to your server console. It will create config_converted.lua named file, you can transfer all items to config_items.lua

Inventory Keybindings

Dragging items ( Hold left click to item )

Research items ( Middle mouse button to unsearched item )

Research containers ( Middle mouse button to UNSEARCHED text or left click to Search )

Hotbar/Fastuse ( Click 3-9 keys in keyboard 1-2 for first and second weapon never be manually changed! )

Context Menu/Attachment Menu ( Right click to item )

Item Split ( Start dragging a item and hold shift, finally drop the grid, Split thing will be appear on screen. )

Custom Images Per Item

Locate html > classes.js inside inventory folder, Find "GetItemImage" and customize with your own.

Custom Container Looking Weird

  • Make sure you created item

  • Find html/clothing.css

.container-grid-youritemname {
    position: absolute;
    width: 250px;
    height: 325px;

    right: 10px;
    top: 390px;
}

.grid-parent-youritemname-yourgridname {
    position: absolute;
    left: 0px;
    top: 57px;
}

Custom Clothing/Container Creation

Locate "config_items.lua" inside inventory folder,

    ["myawesomebag"] = { -- Item id
        ["item"] = {
            _id = "myawesomebag", -- Item code example, /giveitem 1 pasta
            _name = "sport_backpack", -- Item name
            _parent = "c6jgbwjs9tc2vb8gtpwe7rywe", -- Item parent make same, it will adjust itself
            _type = "Item", -- Item type if not an custom object make Item
            _data = {
                Name = "Backpack", -- Item name, its listed in JavaScript
                AttachableSlot = "backpack", -- Item slot, you can adjust for slots. All slots listed bottom of this code snippet
                Label = "Its my bag so awesome", -- Item label
                Description = "", -- Item description, you can see from tooltip
                Width = 4, -- Item width (4-x)
                Height = 3, -- Item height (x-3)
                Weight = 1.5, -- Item weight
                ExamineTime = 3.0, -- Item research speed
                Backgroundcolor = "black", -- Item background color
                ItemSound = "gear_backpack", -- Item sound
                Type = "container", -- Item type, same as upper
                MaxStack = 1, -- Item stack limit
                Grids = { -- If not container make empty
                    [0] = {
                        _name ="mybestgrid", -- Grid identifier (It\'s important)
                        _id ="isntimportant", -- Grid id (You can ignore this)
                        _parent ="myawesomebag", -- Grid parent, make same with item id
                        cellsH = 8, -- Grid height (x-8)
                        cellsV = 4, -- Grid width (4-x)
                    },
                },
                Itemimage = "icons/bag.png", -- Item image
            }
        }
    },

Created custom clothing in lua, but there is 1 process left. UI can looks weird for reason, find html/clothing.css

.container-grid-myawesomebag {
    position: absolute;
    width: 250px;
    height: 325px;

    right: 10px;
    top: 390px;
}

.grid-parent-myawesomebag-mybestgrid {
    position: absolute;
    left: 0px;
    top: 0px;
}

After doing that, custom clothing can be useable. If you want to implement the esx_skin or qb-clothing,

We already created a bag if not make one, For an example, We're gonna edit the backpack 85

                if givinItem == "backpack" then -- Slot name located in config.lua
                    if (itemData == 40 or itemData == 41 or itemData == 44 or itemData == 45 or itemData == 81 or itemData == 82 or itemData == 86) then
                        givinItem = "bag1"
                    elseif (itemData == 85) -- Clothing id, coming from GTA V (Same with esx_skin clothing number)
                        givinItem = "myawesomebag"
                    end

For QBCore

                if givinItem == "backpack" then -- Slot name located in config.lua
                    if (itemData.item == 40 or itemData.item == 41 or itemData.item == 44 or itemData.item == 45 or itemData.item == 81 or itemData.item == 82 or itemData.item == 86) then
                        givinItem = "bag1"
                    elseif (itemData == 85) -- Clothing id, coming from GTA V (Same with qb-clothing clothing number)
                        givinItem = "myawesomebag"
                    end

Inventory Shop Creation

    local ShopItems = {
        ["kurkakola"] = {
            amount = 50,
            price = 12500,
        },
        ["sandwich"] = {
            amount = 5000,
            price = 50,
        }
    }
    exports["ls-inventoryhud"]:ShopInventory("SHOP-XXXXX", "shop1", temporary, ShopItems)

What this mean this variables!

SHOP-XXXXXX

  • Doesnt important thing you can rename noting will be change

  • ( ! IMPORTANT ! DO NOT DELETE SHOP- )

Shop1

  • Is Inventory name in config_items.lua you can customize inventory from location.

  • Its not important and big thing!

Temporary

  • Is equals temporary, make "true"!

ShopItems

  • ShopItems is shop items you can edit freely.

  • You can add or you can remove items, items created with info

  • (DO NOT MORE INFO ITEMS AMOUNT MORE THAN 1 LIKE WEAPONS)

qb-inventory stashes

Locate "ls-inventoryhud > resources > server> functions.lua",

Add this code snippet bottom of functions.lua
RegisterNetEvent('inventory:server:OpenInventory', function(name, id, other)
    if name == "shop" then
        local newShop = {}
		for _,v in pairs(other.items) do
			newShop[v.name] = v
		end
		if Config.Items[name] == nil then name = "shop1" end
		
        TriggerClientEvent("inventory:client:OpenShop", source, name, id, newShop)
    else
		if Config.Items[name] == nil then name = "custom_inventory" end
	
        TriggerClientEvent("inventory:client:OpenInventory", source, name, id, false)
    end
end)

Locate "ls-inventoryhud > resources > client > functions.lua",

Add this code snippet bottom of functions.lua
RegisterNetEvent("inventory:client:OpenInventory", function(tpl, id, temp)
    OpenCustomInventory(id, tpl, temp)
end)

qb-shops

Locate "qb-shops > client > main.lua",

Find openShop and replace
local function openShop(shop, data)
    local products = data.products
    local ShopItems = {}
    ShopItems.items = {}
    QBCore.Functions.TriggerCallback("qb-shops:server:getLicenseStatus", function(hasLicense, hasLicenseItem)
        ShopItems.label = data["label"]
        if data.type == "weapon" then
            if hasLicense and hasLicenseItem then
                ShopItems.items = SetupItems(shop)
                QBCore.Functions.Notify(Lang:t("success.dealer_verify"), "success")
                Wait(500)
            else
                for i = 1, #products do
                    if not products[i].requiredJob then
                        if not products[i].requiresLicense then
                            ShopItems.items[#ShopItems.items + 1] = products[i]
                        end
                    else
                        for i2 = 1, #products[i].requiredJob do
                            if QBCore.Functions.GetPlayerData().job.name == products[i].requiredJob[i2] and not products[i].requiresLicense then
                                ShopItems.items[#ShopItems.items + 1] = products[i]
                            end
                        end
                    end
                end
                QBCore.Functions.Notify(Lang:t("error.dealer_decline"), "error")
                Wait(500)
                QBCore.Functions.Notify(Lang:t("error.talk_cop"), "error")
                Wait(1000)
            end
        else
            ShopItems.items = SetupItems(shop)
        end
        for k in pairs(ShopItems.items) do
            ShopItems.items[k].slot = k
        end
        ShopItems.slots = 30
		local newShop = {}
		for k,v in pairs(ShopItems.items) do
			newShop[v.name] = v
		end
		exports["ls-inventoryhud"]:ShopInventory("SHOP-"..shop, "shop1", true, newShop)
    end)
end

Last updated