# Installation Guide

This guide will provide step-by-step instructions on how to install and set up the KQ\_PLACEABLE\_ITEMS script for FiveM.

### Step 1: <a href="#step-1" id="step-1"></a>

After downloading the script, unzip the folder and place it in the `resources` directory on your FiveM server.

### Step 2: <a href="#step-2" id="step-2"></a>

Open the `config.lua` file in the script folder and make sure that the correct framework is enabled.

When using ox-inventory, set Config.oxInventorySettings > enabled to `true` and disable other frameworks

If you're not using ox-inventory, make sure to disable `Config.oxInventorySettings` > `enabled`

### Step 3: <a href="#step-3" id="step-3"></a>

**\<!> Only needed when using persistent items**

Next, you need to import the `kq_placeable_items.sql` file into your database. This will create the tables required for the script to function properly. You can watch this video for instructions on how to import an SQL file into your database: <https://www.youtube.com/watch?v=xBbqDLXrZGY>.

### Step 4: <a href="#step-4" id="step-4"></a>

After the config file has been set up, add the script to your `server.cfg` file. Make sure that it's added **after** your framework of choice, so that it loads and starts properly.

### Step 5: <a href="#step-5" id="step-5"></a>

Configure the script to your likings. Add your own items and define the corresponding models.

### Done <a href="#done" id="done"></a>

Enjoy the script

***

### OX-Inventory integration <a href="#ox-inventory-integration" id="ox-inventory-integration"></a>

Now if you wish to add a "Place" option to the inventory itself, simply add the following to each item within your ox-inventory items (and weapons) lists

```lua
buttons = {{ label = 'Place', action = function(slot) exports['kq_placeable_items']:placeItem(slot) end }},
```

Here's a full example:

```lua
    ["gold"] = {
        label = "Gold",
        weight = 1,
        stack = true,
        close = true,
        buttons = {{ label = 'Place', action = function(slot) exports['kq_placeable_items']:placeItem(slot) end }},
    },
```

***

This could also be automated. This will requrie a little modification to the items.lua file

At the top of the file, replace the instant return of the items table with:

```lua
local items = {
```

Then at the very bottom of the file add the following code

```lua
for k, item in pairs(items) do
    if not item.buttons then
        item.buttons = {{ label = 'Place', action = function(slot) exports['kq_placeable_items']:placeItem(slot) end }}
    else
        table.insert(item.buttons, { label = 'Place', action = function(slot) exports['kq_placeable_items']:placeItem(slot) end })
    end
end

return items
```

The resulting file should look something like this:

```lua
local items = {

    ['bandage'] = {
        label = 'Bandage',
        weight = 115,
        client = {
            anim = { dict = 'missheistdockssetup1clipboard@idle_a', clip = 'idle_a', flag = 49 },
            prop = { model = `prop_rolled_sock_02`, pos = vec3(-0.14, -0.14, -0.08), rot = vec3(-50.0, -50.0, 0.0) },
            disable = { move = true, car = true, combat = true },
            usetime = 2500,
        }
    },

    ['black_money'] = {
        label = 'Dirty Money',
    },

    ['burger'] = {
        label = 'Burger',
        weight = 220,
        client = {
            status = { hunger = 200000 },
            anim = 'eating',
            prop = 'burger',
            usetime = 2500,
            notification = 'You ate a delicious burger'
        },
    },
}

for k, item in pairs(items) do
    if not item.buttons then
        item.buttons = {{ label = 'Place', action = function(slot) exports['kq_placeable_items']:placeItem(slot) end }}
    else
        table.insert(item.buttons, { label = 'Place', action = function(slot) exports['kq_placeable_items']:placeItem(slot) end })
    end
end

return items
```
