# Installation

{% hint style="danger" %}
You need ***msk\_core***! - [*Download it here*](https://github.com/MSK-Scripts/msk_core)
{% endhint %}

* **Drag & Drop** the folder `msk_vehiclekeys` into your resource folder
* Add ensure `msk_vehiclekeys` in your `server.cfg`
* Configure the `config.lua`
* Set your current Framework at `Config.Framework`
* Set the Hotkeys that you want *(Users can change it by themself in fivem keybind settings)*
* Add the **itemName** in `Config.Settings` to your inventory or database
* Activate or deactivate `uniqueItems` if your are using one of the supported inventories

MSK VehicleKeys don't need any SQL file. All vehicle keys will be saved in `vehiclekeys.json`.

{% hint style="warning" %}
Do NOT add or delete anything in vehiclekeys.json! This will be overwritten as the script saves the data every 5 minutes and when the script was stopped.
{% endhint %}

## Supported Inventories

You must have one of the listed inventories below, but without them, you won’t have unique items!

* [ox\_inventory](https://github.com/overextended/ox_inventory) → <mark style="color:$primary;">recommended</mark>
* [jaksam\_inventory](https://fivem.jaksam-scripts.com/package/7091785) → *Keyring functions <mark style="color:$primary;">supported</mark>*
* [qs-inventory](https://www.quasar-store.com/de/package/6304046) → *Keyring function <mark style="color:red;">not supported</mark>*
* [core\_inventory](https://forum.cfx.re/t/core-inventory-qb-esx-advanced-grid-based-inventory/4859943) → *Keyring function <mark style="color:red;">not supported</mark>*

We have no plans to support further inventories but you can still make suggestions.

{% hint style="success" %}
We recommend using `ox_inventory` for <mark style="color:green;">**Unique Items**</mark> because with this inventory we can Add or Remove the Players Key automatically if he Drops, Give, etc. the Key Item (except TempKeys).&#x20;

Also the Keyring System is currently only for ox\_inventory!
{% endhint %}

{% hint style="info" %}
**Why those features, mentioned above, only for ox\_inventory?**\
Because ox\_inventory offers numerous functions that other inventories unfortunately do not support.

You can find the code for that in `server/main.lua` and for **ox\_inventory** in `server/ox_inventory.lua`. Maybe you can add that yourself...
{% endhint %}

## Items

There are some different items that you need to add to your inventory or database. You can change them in `config.lua` if you want to give them a different name.

* `keys` - The Vehicle Key Item
* `keyring` - Item to open your Keyring *(Only ox\_inventory and jaksam\_inventory)*
* `contract` - Item to sell your vehicle to antoher player *(Put it in a Shop so players can buy it)*

<details>

<summary>ox_inventory</summary>

* Go to `ox_inventory/data/items.lua` and add the items:

{% code title="/data/items.lua" %}

```lua
["keys"] = {
    label = "Vehicle Key",
    description = "Key for a Vehicle",
    weight = 35,
    stack = false,
    close = true,
    client = {
        export = 'msk_vehiclekeys.toggleLock'
    },
},

["contract"] = {
    label = "Contract",
    description = "Contract to sell your vehicle",
    weight = 10,
    stack = true,
    close = true,
    client = {
        export = 'msk_vehiclekeys.openDialog'
    },
},

["keyring"] = {
    label = "Vehicle Keyring",
    description = "Keyring for your Vehicle Keys",
    weight = 10,
    stack = false,
    close = false,
    consume = 0,
},
```

{% endcode %}

* Go to `ox_inventory/modules/items/containers.lua` and add the following:

{% code title="/modules/items/containers.lua" %}

```lua
setContainerProperties('keyring', {
	slots = 500, -- Set Slots
	maxWeight = 100000, -- Set max weight
	whitelist = { 'keys' } -- Do NOT touch this one!
})
```

{% endcode %}

It should look like this:

<img src="https://1100044979-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F6IG4qpnsvwJ4tB5edczg%2Fuploads%2FO0YKhQCj0EGEI3YnddGU%2FScreenshot_25.png?alt=media&#x26;token=a5d54df8-903d-4f81-8d13-26d5740e6218" alt="" data-size="original">

* Restart your server and have fun :)

</details>

<details>

<summary>qs-inventory</summary>

* Go to `qs-inventory\config\metadata.js`
* Go to line \~54 and insert the following:

<pre class="language-javascript"><code class="lang-javascript"><strong>} else if (itemData.name == "keys") { 
</strong>    $(".item-info-title").html("&#x3C;p>" + label + "&#x3C;/p>");
    $(".item-info-description").html(
        itemData.info.description +
        "&#x3C;/span>&#x3C;/p>"
    );
}
</code></pre>

* It should look like this:

```javascript
} else if (itemData.name == "tradingcard_psa") {
    $(".item-info-title").html("<p>" + label + "</p>");
    $(".item-info-description").html(
        "<p><strong>PSA ID: </strong><span>" +
        itemData.info.serial +
        "</span></p>"
    );
 } else if (itemData.name == "keys") {
    $(".item-info-title").html("<p>" + label + "</p>");
    $(".item-info-description").html(
        itemData.info.description +
        "</span></p>"
    );
} else if (itemData.name == "photo") {
    $(".item-info-title").html("<p>" + `${itemData.info.label || label}` + "</p>");
    $(".item-info-description").html(
        "<p><span>" +
        itemData.info.location +
        "</span></p><span>" +
        itemData.info.date + "</span></p>"
    );
}
```

* Then go to `qs-inventory\shared\items.lua` and insert the keys item

```lua
['keys'] = { -- must be the same as in your msk_vehiclekeys config.lua (itemName = 'keys',) 
    ['name'] = 'keys', -- must be the same as in your msk_vehiclekeys config.lua (itemName = 'keys',) 
    ['label'] = 'Vehicle Key',
    ['weight'] = 35,
    ['type'] = 'item',
    ['image'] = 'keys.png',
    ['unique'] = true,
    ['useable'] = true,
    ['shouldClose'] = true,
    ['combinable'] = nil,
    ['description'] = 'Key for a Vehicle'
},

['contract'] = { -- must be the same as in your msk_vehiclekeys config.lua (itemName = 'contract',) 
    ['name'] = 'contract', -- must be the same as in your msk_vehiclekeys config.lua (itemName = 'contract',) 
    ['label'] = 'Contract',
    ['weight'] = 1,
    ['type'] = 'item',
    ['image'] = 'contract.png',
    ['unique'] = false,
    ['useable'] = true,
    ['shouldClose'] = true,
    ['combinable'] = nil,
    ['description'] = 'Contract to sell your vehicle'
},
```

</details>
