# QBCore Install

## Step 1. Remove Old Clothing Resources <a href="#remove-old-clothing-resources" id="remove-old-clothing-resources"></a>

Delete `qb-clothing` or `illenium-appearance` from your resources folder

Delete any tattoo shop resources e.g. `qb-tattooshop` from your resources folder

{% hint style="warning" %}
If you are migrating from illenium-appearance, you can skip these steps and jump to the [migration section](https://fivem.lvsoft.com.ar/qb-esx/lvs-clothing/migration/illenium-appareance)
{% endhint %}

***

## Step 2. Install dependencies <a href="#install-dependencies" id="install-dependencies"></a>

Install the dependencies if they are not installed.

| oxmysql | <https://github.com/overextended/oxmysql> |
| ------- | ----------------------------------------- |
| ox\_lib | <https://github.com/overextended/ox_lib>  |

***

## Step 3. Download lvs\_clothing <a href="#download-illenium-appearance" id="download-illenium-appearance"></a>

Drag And Drop, put `lvs_clothing` in `resources` folder

***

## Step 4. SQL <a href="#add-it-to-your-server" id="add-it-to-your-server"></a>

{% hint style="danger" %}
If you want to migrate skins don't delete the `playerskins` table from your database.\
How to migrate [here](https://fivem.lvsoft.com.ar/qb-esx/lvs-clothing/migration).
{% endhint %}

Delete the `playerskins` table from your database

Delete the `player_outfits` table from your database

Run the **database.sql** file located in the resource folder in your database! Or execute the SQL:

```sql
CREATE TABLE IF NOT EXISTS `playerskins` (
    `id` int(11) NOT NULL AUTO_INCREMENT,
    `citizenid` varchar(255) NOT NULL,
    `model` varchar(255) NOT NULL,
    `skin` text NOT NULL,
    `active` tinyint(4) NOT NULL DEFAULT 1,
    PRIMARY KEY (`id`),
    KEY `citizenid` (`citizenid`),
    KEY `active` (`active`)
    ) ENGINE=InnoDB AUTO_INCREMENT=1 DEFAULT CHARSET=latin1;


CREATE TABLE IF NOT EXISTS `player_outfits` (
    `id` int(11) NOT NULL AUTO_INCREMENT,
    `citizenid` varchar(50) DEFAULT NULL,
    `outfitname` varchar(50) NOT NULL DEFAULT '0',
    `tags` varchar(50) DEFAULT NULL DEFAULT 'No Tags',
    `model` varchar(50) DEFAULT NULL,
    `props` varchar(1000) DEFAULT NULL,
    `components` varchar(1500) DEFAULT NULL,
    PRIMARY KEY (`id`),
    UNIQUE KEY `citizenid_outfitname_model` (`citizenid`,`outfitname`,`model`),
    KEY `citizenid` (`citizenid`)
    ) ENGINE=InnoDB AUTO_INCREMENT=1 DEFAULT CHARSET=utf8mb4;
```

***

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

Now configure and translate your resource.

<details>

<summary>Config files</summary>

`/config/config.lua`\
`/config/blacklist.lua`\
`/config/cloakroom.lua`\
`/config/peds.lua`\
`/config/stores.lua`\
`/config/target.lua`\
`/config/tattoos.lua`\
`/config/ui.lua`

</details>

***

## Step 6. Script initiate <a href="#step-6" id="step-6"></a>

Start the script in **server.cfg** , `ensure lvs_clothing.`

***

## Step 7. qb-multicharacter

Open `qb-multicharacter/server/main.lua` find the callback `qb-multicharacter:server:getSkin` (line 198) and replace with:

```lua
QBCore.Functions.CreateCallback("qb-multicharacter:server:getSkin", function(_, cb, cid)
    local result = MySQL.query.await('SELECT * FROM playerskins WHERE citizenid = ? AND active = ?', {cid, 1})
    if result[1] ~= nil then
        cb(json.decode(result[1].skin))
    else
        cb(nil)
    end
end)
```

Open `qb-multicharacter/client/main.lua` find the nuicallback `RegisterNUICallback('cDataPed', function(nData, cb)` (line 206) and replace with:

```lua
RegisterNUICallback('cDataPed', function(nData, cb)
    local cData = nData.cData
    SetEntityAsMissionEntity(charPed, true, true)
    DeleteEntity(charPed)
    if cData ~= nil then
        if not cached_player_skins[cData.citizenid] then
            local temp_model = promise.new()
            local temp_data = promise.new()

            QBCore.Functions.TriggerCallback('qb-multicharacter:server:getSkin', function(data)
		local model = data.model or "mp_m_freemode_01"
                temp_model:resolve(model)
                temp_data:resolve(data)
            end, cData.citizenid)

            local resolved_model = Citizen.Await(temp_model)
            local resolved_data = Citizen.Await(temp_data)

            cached_player_skins[cData.citizenid] = {model = resolved_model, data = resolved_data}
        end

        local model = cached_player_skins[cData.citizenid].model
        local data = cached_player_skins[cData.citizenid].data

        if model ~= nil then
            initializePedModel(model, data)
        else
            initializePedModel()
        end
        cb("ok")
    else
        initializePedModel()
        cb("ok")
    end
end)
```
