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


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

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

Last updated