Integration
Exports, preset system, and integration guide for legacy-shops
Client Exports#
OpenStore#
Opens the store UI for a specific shop by its database ID.
exports['legacy-shops']:OpenStore(shopId)
| Parameter | Type | Required | Description |
|---|---|---|---|
shopId | number | Yes | The shop's database ID |
Example
-- Open shop with ID 3
exports['legacy-shops']:OpenStore(3)
The store UI displays all items grouped by category, shows the player's cash and bank balance, and handles the purchase flow.
OpenCreator#
Opens the admin shop creator panel.
exports['legacy-shops']:OpenCreator()
This export performs an admin permission check before opening. Non-admin players will see an error notification.
Preset System#
Presets are shop templates that pre-configure a shop's name, ped model, blip settings, categories, and items. When an admin creates a new shop and selects a preset, all of the preset's data is automatically applied.
Default Presets#
The following presets are seeded on first startup if the presets table is empty:
| Preset | Ped Model | Blip Sprite | Categories |
|---|---|---|---|
| General Store | mp_m_shopkeep_01 | 52 | Food & Drinks, Medical, Supplies |
| Digital Den | s_m_y_xmech_02 | 521 | Phones, Accessories, Storage |
| Hardware Store | s_m_m_strvend_01 | 566 | Tools, Materials, Automotive |
| Ammunation | s_m_y_ammucity_01 | 110 | Weapons, Ammo, Armor & Gear |
| Clothing Store | s_f_y_shop_mid | 73 | Tops, Bottoms, Accessories |
| Pharmacy | s_m_m_doctor_01 | 61 | Medicine, First Aid, Wellness |
| Bar / Nightclub | s_f_y_bartender_01 | 93 | Drinks, Snacks, Specials |
| Fishing Store | s_m_m_fisherman | 68 | Rods & Tackle, Bait, Accessories |
Custom Presets#
Admins can create and manage custom presets through the creator UI. Custom presets are stored in the legacy_shops_presets table and support:
- Custom name and label
- Ped model selection
- Blip sprite, color, and scale
- Custom category lists
- Pre-configured item lists with prices and stock levels
Item labels and images are automatically resolved from ox_inventory at runtime, so presets only store the item name, category, price, and stock values.
Price Fluctuation#
When Config.FluctuationEnabled is true, the server recalculates randomized prices for all items at the interval defined by Config.FluctuationInterval. Each item gets a random modifier between -FluctuationRange% and +FluctuationRange% applied to its base price.
Key details:
- The minimum fluctuated price is always
$1(never zero or negative) - Base prices in the database are never modified
- Fluctuated prices are calculated server-side and sent to clients on shop open
- All players see the same fluctuated prices until the next recalculation
Restock System#
When Config.RestockEnabled is true, items with limited stock are automatically restocked on a timer.
Key details:
- Only items with
stock >= 0andmax_stock > 0are restocked - Items with
stock = -1(unlimited) are never affected - Each tick adds
RestockPercent%ofmax_stockto the current stock, capped atmax_stock - Stock updates are saved to the database and all clients are notified
Stock Values#
Stock behavior is controlled by two fields on each item:
| Value | stock | max_stock | Behavior |
|---|---|---|---|
| Unlimited | -1 | -1 | Item never runs out, not restocked |
| Limited | 50 | 100 | Starts at 50, restocked up to 100 |
| Out of stock | 0 | 100 | Cannot be purchased until restocked |
Purchase Flow#
- Player interacts with a shop ped to open the store
- Items are displayed with their fluctuated prices (if enabled) and current stock
- Player adds items to cart and selects a payment method (cash or bank)
- Server validates: item availability, stock levels, carry capacity, and sufficient funds
- On success: funds are deducted, items are added to inventory, stock is updated, and the purchase is logged to
legacy_shops_history
Database Tables#
legacy_shops_history#
All purchases are logged for auditing:
| Column | Type | Description |
|---|---|---|
shop_id | INT | The shop where the purchase occurred |
identifier | VARCHAR(100) | Player framework identifier |
player_name | VARCHAR(100) | Player's character name |
item_name | VARCHAR(100) | Item purchased |
quantity | INT | Quantity purchased |
price_paid | INT | Total price paid for this item |
payment_method | VARCHAR(20) | 'cash' or 'bank' |
purchased_at | TIMESTAMP | Timestamp of purchase |