# Basics, Configurations, Exports & Events

## Basics

### Item Creation

Item creation is basic, just locate <mark style="color:yellow;">configs/config\_items.lua</mark> open file after that,

{% code overflow="wrap" %}

```lua
    ['example_item'] = { -- Item code to give
        ['name'] = 'example_item', -- Item code to give
        ['label'] = 'Our Example Item', -- Item display name
        ['weight'] = 100, -- Item weight calculated in grams because QB
        ['type'] = 'item', -- Item type is unneccesary, its affects only weapons.
        ['image'] = 'example_item_image.png', -- Item image, needs to be located at "web/images/xxx.png"
        ['unique'] = true, -- This means your items cannot be merged each other
        ['useable'] = true, -- This means your item can be useable
        ['shouldClose'] = true, -- This means usage will close your inventory UI
        ['combinable'] = nil, -- Unneccesary
        ['description'] = 'Our best example item!' -- Item tooltip description
    },
```

{% endcode %}

### Item Converter

{% hint style="warning" %}
If you have customized values, locate <mark style="color:yellow;">server/items-convert.lua</mark>, and customize to your server.
{% endhint %}

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

## Exports & Events

### Server Side Exports

UseItem - Its made for item useage.

```lua
exports["ls-inventory"]:UseItem(itemData.name, src, itemData)
```

SetMainItems - Sets ls-core items data

```lua
exports["ls-inventory"]:SetMainItems(source, items)
```

**LoadInventory** - Loads player inventory.

```lua
exports["ls-inventory"]:LoadInventory(source, identifier)
```

SaveInventory  - Saves player inventory.

```lua
exports["ls-inventory"]:SaveInventory(source)
```

GetTotalWeight - Gets items total weight.

```lua
exports["ls-inventory"]:GetTotalWeight(items)
```

GetSlotsByItem - Gets slots by itemname.

```lua
exports["ls-inventory"]:GetSlotsByItem(items, itemName)
```

GetFirstSlotByItem - Gets first slot by itemname.

```lua
exports["ls-inventory"]:GetFirstSlotByItem(items, itemName)
```

AddItem - Adds an item to player inventory.

```lua
exports["ls-inventory"]:AddItem(source, itemName, amount, slot, info)
```

RemoveItem - Removes an item to player inventory.

```lua
exports["ls-inventory"]:RemoveItem(source, item, amount, slot)
```

GetItemBySlot - Gets items from slot.

```lua
exports["ls-inventory"]:GetItemBySlot(source, slot)
```

GetItemByName - Gets items from name.

```lua
exports["ls-inventory"]:GetItemByName(source, name)
```

GetItemsByName - Gets items from slot.

```lua
exports["ls-inventory"]:GetItemsByName(source, name)
```

ClearInventory - Clears player inventory.

```lua
exports["ls-inventory"]:ClearInventory(source)
```

SetInventory - Sets player inventory.

```lua
exports["ls-inventory"]:SetInventory(source)
```

SetItemData - Sets player item data.

```lua
exports["ls-inventory"]:SetItemData(source, itemName, infoKey, infoValue)
```

HasItem - Checks player has item.

```lua
exports["ls-inventory"]:HasItem(source, itemName, amount)
```

### Client Side Exports

CloseInventory - Closes player inventory.

```lua
exports["ls-inventory"]:CloseInventory()
```

RobPerson - Opens second player inventory.

```lua
exports["ls-inventory"]:RobPerson(slot)
```

SetInventoryClothings - Sets player inventory clothings.

```lua
exports["ls-inventory"]:SetInventoryClothings()
```

### Client Side Events

inventory:c:giveClothesAsItem - Gives player clothings to as item.

{% code overflow="wrap" %}

```lua
TriggerClientEvent("inventory:c:giveClothesAsItem", currentSkin, oldSkin, firstTime) -- Server Side
TriggerEvent("inventory:c:giveClothesAsItem", currentSkin, oldSkin, isFirst) -- Client Side
```

{% endcode %}

{% hint style="danger" %}
Some clothing system uses different types, for that reason if you dont know how to enter oldSkin only use like,

{% code overflow="wrap" %}

```lua
TriggerClientEvent("inventory:c:giveClothesAsItem", currentSkin, {}, true) -- Server Side
TriggerEvent("inventory:c:giveClothesAsItem", currentSkin, {}, true) -- Client Side
```

{% endcode %}
{% endhint %}

### Server Side Events

inventory:server:openInventory - Opens player inventory.

{% code overflow="wrap" %}

```lua
TriggerServerEvent("inventory:server:openInventory", inventoryType, inventoryId, otherStuff) -- Server Side
TriggerEvent("inventory:c:giveClothesAsItem", source, inventoryType, oldinventoryIdSkin, otherStuff) -- Client Side
```

{% endcode %}

{% hint style="success" %}
inventoryType mostly requires <mark style="color:yellow;">"stash"</mark>.\
otherStuff is an <mark style="color:green;">unneccesary</mark> stuff,  you can only enter <mark style="color:yellow;">{ maxweight = weight, slots = slot}</mark>.

inventoryId needs to be <mark style="color:red;">unique</mark>.
{% endhint %}
