# Basics

## Custom Inventory Creation

Locate <mark style="color:purple;">**"config\_items.lua"**</mark> 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. \
\
\&#xNAN;*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 <mark style="color:purple;">**"config\_items.lua"**</mark> 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.

{% hint style="danger" %}
Config.Debug, can causes bunch errors! Do not true in running server.
{% endhint %}

## Item Convert! (QB-ESX)

{% hint style="warning" %}
If you have customized values, locate resources/server/items-convert.lua, and customize to your server.
{% endhint %}

Start your server, enter the <mark style="color:purple;">**"convertitems"**</mark> to your server console. It will create <mark style="color:purple;">**config\_converted.lua**</mark> named file, you can transfer all items to <mark style="color:purple;">**config\_items.lua**</mark>

## 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. )

{% hint style="danger" %}
Inventory can be opened using F2, if you join the server for one time, F2 saved FiveM keybindings inside of GTA 5! If you change the F2, before joined users keep used F2 key!
{% endhint %}

## Custom Images Per Item

Locate <mark style="color:purple;">**html > classes.js**</mark> inside inventory folder, Find <mark style="color:purple;">**"GetItemImage"**</mark> 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

{% hint style="warning" %}
This example given for Clothing, same process can applicable for containers!
{% endhint %}

Locate <mark style="color:purple;">**"config\_items.lua"**</mark> 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 <mark style="color:purple;">**html/clothing.css**</mark>

```
.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
```

{% hint style="warning" %}
**All Clothing Slots**\
top,                               Defined for player torso.\
shirts,                           Defined for player t-shirt.\
pants,                           Defined for player pants.\
backpack,                    Defined for player bag/backpack\
shoes,                          Defined for player shoes\
mask                            Defined for player mask\
rig                                 Defined for player armor/bulletproof\
gloves                          Defined for player gloves/arms\
hat                               Defined for player hat/helmet\
ear                               Defined for player ears\
watch                          Defined for player watches\
glasses                        Defined for player glasses\
bracelet                      Defined for player bracelets
{% endhint %}

## 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 <mark style="color:purple;">**"ls-inventoryhud > resources > server>  functions.lua",**</mark>

{% code title="Add this code snippet bottom of functions.lua" lineNumbers="true" %}

```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)
```

{% endcode %}

Locate <mark style="color:purple;">**"ls-inventoryhud > resources > client > functions.lua",**</mark>

{% code title="Add this code snippet bottom of functions.lua" lineNumbers="true" %}

```lua
RegisterNetEvent("inventory:client:OpenInventory", function(tpl, id, temp)
    OpenCustomInventory(id, tpl, temp)
end)
```

{% endcode %}

## qb-shops

Locate <mark style="color:purple;">**"qb-shops > client  > main.lua",**</mark>

{% code title="Find openShop and replace" lineNumbers="true" %}

```lua
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
```

{% endcode %}
