Systems Overview

Architecture, config fields, stock, schedules, and server events

Architecture

Key files:

  • shared/config.lua holds Config.Traders and the global restock settings.

  • server/server.lua builds activeTraders, registers trader shops, validates trades, opens shops, and updates live stock.

  • escrow client files spawn the peds, sync them, build menus, and open the shop UI.

On resource start, the server picks one random location from each trader's locations list.

If a trader has a shop, the server registers it as trader_shop_{i}.

Then the active trader list syncs to clients.

Trader entries

Common fields:

  • name

  • model

  • locations

  • greetings

  • trade

  • shop

  • schedule

  • serverTimeSchedule

  • blip

  • tradeDialogue

Trade vs shop

Trade

Trade is barter.

The server validates required items, then completes the exchange.

Trade definitions usually include:

  • wants

  • gives

  • optional animation or prop

  • optional group restrictions

  • optional refusal message

Shop

Shop is a registered cash shop.

The server checks distance, schedule, and group access before opening it.

Shop groups use job or gang names mapped to minimum grade.

Stock and restock

Each shop stock row can include:

  • price

  • count

  • label

  • restockRate

  • stockLimit

  • optional metadata

Global restock comes from:

  • Config.Settings.RefreshStock

  • Config.Settings.RestockTime

The stock thread tops items back up toward their stock limit.

Schedules

schedule uses the script's hour check for in-game style hours.

serverTimeSchedule uses the same hour logic for real server clock windows.

Overnight ranges are supported.

Server events

Common internal events:

  • envi-traders:syncTraders

  • envi-traders:server:processTrade

  • envi-traders:server:openShop

  • envi-traders:server:itemPurchased

There are no packaged public exports in the current docs.

Integrate around the registered shop name pattern or extend the server file if you need custom APIs.

Last updated