> For the complete documentation index, see [llms.txt](https://cosmos-studios.gitbook.io/documentation/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://cosmos-studios.gitbook.io/documentation/scripts/territories/installation.md).

# Installation

## QBCore Installation

If you are using qbcore make sure that in the "config.lua" file the Config.Framework section is set to "QBCore", otherwise change it to QBCore.

{% hint style="danger" %}
QBCore only supports inventories that work with the QBCore inventory table. If you are not using the qb-inventory, selling drugs to NPCs may not work, so it must be disabled.
{% endhint %}

{% hint style="info" %}
If you have modified the "PlayerData" structure and the script has errors, you must make the table that receives the script equal to the default one. You can edit the tables that are received in "**custom.lua**" on serverside and clientside. <mark style="color:yellow;">If you have not modified the "default" table structure ignore this warning</mark>.
{% endhint %}

### Database Configuration

In QBCore the script will only store the data in the script's .json file, it **will not require any database**.

> ### ℹ️ Reset territories saved data
>
> To reset the data of the territories, you will need to have the script or server stopped. Then, access the .json file named 'territories.json' and delete all the text.&#x20;
>
> Once the file is empty, write \[] and save the changes. The structure will be regenerated when the script is restarted.

**This will be what the .json will look like:**

{% code title="territories.json" %}

```json
[]
```

{% endcode %}

### Item Creation

To add the preconfigured drug items you must go to "qb-core", shared, items.lua.

{% code title="items.lua" fullWidth="false" %}

```lua
-- CS-TERRITORIES
weed = { name = 'weed', label = 'Weed bag', weight = 100, type = 'item', image = 'weed.png', unique = false, useable = false, description = 'A small bag with weed' },
weed = { name = 'cocaine', label = 'Cocaine bag', weight = 100, type = 'item', image = 'cocaine.png', unique = false, useable = false, description = 'A small bag with cocaine' },
weed = { name = 'meth', label = 'Meth bag', weight = 100, type = 'item', image = 'meth.png', unique = false, useable = false, description = 'A small bag with meth' },
```

{% endcode %}

### Inventory images

{% file src="/files/5W11MbcCz8dGzdL27sNg" %}

{% file src="/files/N7Zn1g8Varf0SU8YhxSu" %}

{% file src="/files/Z0OR3IikbTNM2wTxd1KK" %}

***

## ESX Installation

<mark style="color:blue;">The installation on ESX may take longer than on QBCore, so it's recommended to set up the script with time and patience.</mark>

To start, it will be necessary to set the section 'Config.Framework' in the 'config.lua' file to 'ESX' for the script to function correctly.

{% hint style="info" %}
Excluding anything related to selling to NPCs, the only request the script will make to the core is to obtain the character identifier to create their table.
{% endhint %}

In the ESX version, it will indeed be necessary to load the .sql file into the database. The script will come prepared to work with either [oxmysql](https://github.com/overextended/oxmysql) or [icmysql](https://github.com/IceClusters/icmysql/tree/main). This can be configured in the 'config.lua' file under the section 'Config.DBConnector'.

```lua
Config.DBConnector = "oxmysql" -- "oxmysql" or "icmysql"
```

{% hint style="info" %} <mark style="color:yellow;">All database connections are not encrypted with escrow. In case you want to use another connector or a different database, it can be modified by the user.</mark>
{% endhint %}

### ESX Configuration

In ESX, we'll need to create gangs within the script. For this, we'll have an entire directory within the script dedicated to the 'minicore' so that organizations can function in ESX.

<mark style="color:green;">cs-territories\gangsystem</mark> It will be the directory containing everything related to player tables. **This directory will not be protected by escrow, it will be entirely accessible to the user**.

To add or modify organizations, you'll need to go to the 'gangs.lua' file within the 'shared' directory.


---

# Agent Instructions
This documentation is published with GitBook. GitBook is the documentation platform designed so that both humans and AI agents can read, navigate, and reason over technical content effectively. Learn more at gitbook.com.

## Querying This Documentation
If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://cosmos-studios.gitbook.io/documentation/scripts/territories/installation.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
