# Setup

<mark style="background-color:yellow;">**Supports: QBCore QBOX, ESX, Custom Frameworks**</mark>

***

### Configuration Guide

This guide will walk you through the configuration options&#x20;

#### General Settings

<figure><img src="/files/YVpdUDhGDDTlcqRSdePJ" alt=""><figcaption></figcaption></figure>

This section covers general settings for the shops.

* `Config.Settings.Interaction`:
  * `useTextUI`: Set to `true` to use a text-based UI for interactions.
  * `openKey`: The key used to open the shop when using TextUI. The default is `38` (E key).
  * `useTarget`: Set to `true` to use a target system for interactions.
  * `Target`: Specify the target system you are using (e.g., `'qb-target'` or `'ox_target'`).
* `Config.Settings.AllItemsTab`:
  * `Enable`: Set to `true` to include an "All Items" tab in the shops.
  * `categoryName`: The name of the "All Items" category (e.g., `'All Items'`).
  * `categoryLogo`: The Font Awesome icon for the "All Items" category (e.g., `'fa-globe'`).
* `Config.Settings.stockFeature`: Set to `true` to enable the item stock feature. If enabled, items can run out of stock.
* `Config.Settings.useInventoryImage`: Set to `true` to use images from your inventory folder. If `false`, it will fetch images from `cs_shops/ui/image`.
* `Config.Settings.EnableSearch`: Set to `true` to enable the search feature in shops.
* `Config.Settings.EnableMouseControl`: Set to `true` to enable mouse controls in the UI.
* `Config.Settings.maxPurchaseAmount`: The maximum amount of an item that can be purchased at once. The default is `100`.

***

#### Products

This section allows you to define the items that can be purchased in the shops. Items are organised into categories.

Here's an example of a single item entry:

```lua
{
    item = 'tosti',         -- The item's spawn name
    itemName = "Tosti",     -- The item's display name
    itemStock = 50,         -- The available stock of the item
    itemPrice = 2,          -- The price of the item
    itemInfo = "Delicious grilled sandwich", -- A description of the item

    --  OPTIONAL --
    itemMetaData = {},         -- For item metadata
    requiredJob = false,       -- Restrict to jobs and grades (e.g., {['police'] = {1,2}, ['taxi'] = {1}})
    requiredGang = false,      -- Restrict to gangs and grades (QB-Core only) (e.g., {['ballas'] = {1,2}, ['lostmc'] = {1}})
    requiredLicense = false    -- Require a specific license (e.g., {'weapon', 'driver'})
},
```

You can create multiple categories, such as `normal`, `liquor`, `hardware`, `weapons`, `ammo`, etc., and add items to each category.

***

#### Sell Categories

This section is where you define the items that players can sell.

* `Config.SellCategories`: This table contains categories of sellable items. For each item, you set the price it can be sold for.

Example:

```lua
Config.SellCategories = {
    ['electronics'] = {
        categoryName = "Electronics",
        categoryLogo = "fa-solid fa-microchip",
        items = {
            ['phone'] = 425,
            ['radio'] = 125,
        }
    },
    -- ... other categories
}
```

***

#### Shops

This is where you define the actual shop locations and their properties.

Here's an example of a shop configuration:

```lua
[1] = {
    ShopName = 'General Store',
    shopType = 'both',  -- 'buy', 'sell', or 'both'
    Category = {
        [1] = 'normal',
        [2] = 'liquor',
    },
    SellCategory = {
        [1] = 'electronics',
        [2] = 'tools',
    },
    Locations = {
        vector4(24.47, -1346.62, 29.5, 271.66),
        -- ... other locations
    },
    Interaction = {
        targetIcon = 'fas fa-shopping-basket',
        targetLabel = 'Open General Store',
        spawnPed = 'mp_m_shopkeep_01',
        scenario = 'WORLD_HUMAN_STAND_MOBILE',
        radius = 2.5,
    },
    Blips = {
        Enable = true,
        blipsprite = 52,
        blipscale = 0.6,
        blipcolor = 0,
    }
},
```

* `ShopName`: The name of the shop.
* `shopType`: Can be `'buy'`, `'sell'`, or `'both'`.
* `Category`: A table defining the product categories available in this shop.
* `SellCategory`: A table defining which sell categories this shop accepts.
* `Locations`: A table of `vector4` coordinates for each shop location.
* `Interaction`:
  * `targetIcon`: The icon for the target system.
  * `targetLabel`: The label that appears on the target.
  * `spawnPed`: The ped model to spawn at the shop. Set to `false` if no ped is needed.
  * `scenario`: The animation scenario for the ped.
  * `radius`: The interaction radius.
* `Blips`:
  * `Enable`: Set to `true` to show a map blip for the shop.
  * `blipsprite`, `blipscale`, `blipcolor`: Blip properties.

***

#### Webhook Logging

<figure><img src="/files/m0xgfdMrMxAckLE4DZwi" alt=""><figcaption></figcaption></figure>

You can set up a Discord webhook to log shop transactions *<mark style="color:$info;">**(cs\_shops/config/functions/sv\_function.lua)**</mark>*

* `Config.Webhook.enabled`: Set to `true` to enable webhook logging.
* `Config.Webhook.url`: Your Discord webhook URL.
* `Config.Webhook.username`: The username that will appear in the webhook.
* `Config.Webhook.purchase`: Settings for purchase logs, including `embedColor` and `title`.
* `Config.Webhook.sell`: Settings for sell logs, including `embedColor` and `title`.

***

#### *<mark style="background-color:$info;">**Additional detailed guidance can be found in the config itself. If you need further assistance, please feel free to contact us on Discord.**</mark>*


---

# Agent Instructions: 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://codestudio5m.gitbook.io/codestudio/our-scripts/modern-shops/setup.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.
