How to Add Shop

How to Add Shops

To prevent shops from being manipulated by cheaters, all shop details must be securely registered on the server. There are two available methods to register shops:


1. Registering a Shop via Export

You can use the RegisterShop export to register a shop directly from the server side. 🔗 Documentation: RegisterShop Export

Example

local items = {
    { name = 'beer',    price = 7,  amount = 50, type = 'item' },
    { name = 'whiskey', price = 10, amount = 50, type = 'item' },
    { name = 'vodka',   price = 12, amount = 50, type = 'item' },
}

exports["tgiann-inventory"]:RegisterShop("policeshop2", items)

2. Registering a Shop via Config File

Alternatively, you can define shops directly through the configuration file.

Steps

  1. Open the configShop.lua file.

  2. Inside the config.Products table, add a new key with the shop name and define the items you want to sell.

Example

config.Products = {
    ['normal'] = {
        { name = 'tosti',         price = 2,   amount = 50,   type = 'item' },
        { name = 'water_bottle',  price = 2,   amount = 50,   type = 'item' },
        { name = 'kurkakola',     price = 2,   amount = 50,   type = 'item' },
        { name = 'twerks_candy',  price = 2,   amount = 50,   type = 'item' },
        { name = 'snikkel_candy', price = 2,   amount = 50,   type = 'item' },
        { name = 'sandwich',      price = 2,   amount = 50,   type = 'item' },
        { name = 'beer',          price = 7,   amount = 50,   type = 'item' },
        { name = 'whiskey',       price = 10,  amount = 50,   type = 'item' },
        { name = 'vodka',         price = 12,  amount = 50,   type = 'item' },
        { name = 'bandage',       price = 100, amount = 50,   type = 'item' },
        { name = 'lighter',       price = 2,   amount = 50,   type = 'item' },
        { name = 'rolling_paper', price = 2,   amount = 5000, type = 'item' },
    },
    ['policeshop2'] = {
        { name = 'beer',    price = 7,  amount = 50, type = 'item' },
        { name = 'whiskey', price = 10, amount = 50, type = 'item' },
        { name = 'vodka',   price = 12, amount = 50, type = 'item' },
    },
}

How to Open Shops

There are three different ways to open a shop in-game:


1. Using the OpenShop Export

You can open a registered shop using the OpenInventory export. 🔗 Documentation: OpenInventory Export


2. Triggering the Shop from the Client

You can also open shops from the client side using an event. 🔗 Documentation: Client Events

Example

TriggerServerEvent("inventory:server:OpenInventory", "shop", shopName)

Note: This event will not work if config.disableClientOpenInventory is set to true.


3. Defining Shop Locations in Config

You can make shops appear in specific locations by adding entries to config.ShopLocations inside the configShop.lua file.

Example

config.ShopLocations = {
    {
        job = "police",           -- job name (remove this line to make it accessible to everyone)
        productsName = "weapons", -- matches a key name from config.Products
        text = {
            tr = "Polis Silah Dükkanı",
            en = "Police Weapon Shop",
        },
        maxDistance = 3,
        pressDistance = 2,
        blip = {
            active = true,
            sprite = 16,
            scale = 0.7,
            color = 2,
            label = {
                tr = "Polis Silah Dükkanı",
                en = "Police Weapon Shop",
            }
        },
        locations = {
            {
                ped = `ig_terry`,
                coords = vector4(16.6227, -1110.8431, 29.7970, 243.8756),
                moneyType = "bank"
            },
            {
                ped = `ig_terry`,
                coords = vector4(427.2638, -985.6949, 30.7112, 356.5403),
                blipDisable = true
            },
        }
    },
}

Last updated