Exports
This script allows registering and opening dynamic shops on your FiveM server using simple exports and events.
Export: exports.lvs_shops:RegisterShop
exports.lvs_shops:RegisterShop
Syntax (server-side)
exports.lvs_shops:RegisterShop(shopId, shopData)
Parameters
shopId (string): A unique identifier for the shop.
shopData (table): A table containing the shop's settings and inventory.
shopData Structure
name (string): Display name of the shop.
inventory (table): A list of items available in the shop. Each item should be a table with:
name
(string): Item name.price
(number): Item price.type
(string, optional): Item type (for categorization or filtering).
groups (table): Restriction list based on player groups (e.g.,
police = 0
for group access).description (string, optional): A short description of the shop.
filters (table, optional): Used to organize shop items by categories. Each filter is a table with:
type
(string): The item type this filter applies to.label
(string): Display label for the filter.description
(string): Additional description for the filter.icon
(string): Icon for the filter (currently not implemented).
Example Usage
exports.lvs_shops:RegisterShop('TestShop', {
name = 'Test shop',
inventory = {
{ name = 'burger', price = 10, type = 'drink' },
{ name = 'water', price = 10, type = 'drink' },
{ name = 'cola', price = 10, type = 'drink' },
},
groups = {
police = 0
},
description = 'Some description bla bla',
filters = {
{
type = 'drink',
label = 'Drinks',
description = 'Something refreshing',
}
},
})
Event: lvs_shops:client:openRuntimeShop
lvs_shops:client:openRuntimeShop
Syntax (client-side)
TriggerEvent('lvs_shops:client:openRuntimeShop', shopId)
Parameters
shopId (string): The ID of the shop you registered previously.
Description
This client-side event opens the specified runtime shop UI for the player.
Example Usage
TriggerEvent('lvs_shops:client:openRuntimeShop', 'TestShop')
Notes
shopId
must be unique when registering a new shop to avoid conflicts.You can expand the
shopData
with more optional fields like inshops.lua
oflvs_shops
if needed.Group restrictions (
groups
) allow you to make certain shops accessible only to specific player groups or jobs.
Last updated