F.A.Q
Setup
Players with admin permission from the framework or ACE. The admin groups are set once in ml_bridge with Config.AdminPermissions.
- The trader is active in the admin panel
- Its opening hours include the current hour
- You are within
Config.Settings.PedSpawnDistance - The ped model exists on your server
The item name must match an item of your inventory, the item needs a category, and its stock must be above 0 or infinite. An item locked by job or skill is hidden from players who do not meet the lock. Turn on "Show it locked instead of hiding it" on the item and players see it greyed out with a padlock and the requirement.
Prices and Stock
Yes. Every item has a list of costs. Each cost is money from an account (cash, bank or either) or an inventory item. Mix both for barter, for example 200 cash plus 3 scrap metal.
Set a number instead of infinite. Stock goes down with every purchase and updates live on every open shop window. With restock on restart, the item goes back to its default stock when the server starts. The admin panel can also restock a whole shop at once.
Items can have job discounts, with an optional minimum grade, and ml_skills discounts. They add up and are capped by Config.MaxDiscountPercent. Change the math in CalculatePlayerDiscount in open/handlers_server.lua.
Yes. Set metadata on the item in the admin panel. Each value can be fixed, a random number between a minimum and a maximum, a random pick from a list, or a pick weighted by chance. The value is rolled on every purchase.
Traders
Yes. Give the trader extra positions and put it in a trader group. The group moves its traders to a random position every few minutes, between the minimum and maximum set on the group.
Yes. Set opening hours on the trader, on game time or real time. Outside those hours the NPC and its blip are gone.
Yes. Duplicate copies the trader with its items and positions. The copy starts paused on the same spot, so you can move it before you resume it.
Integration
Yes. Call exports['ml_shops']:openShop(shopId) on the client and list the shop in Config.AllowVirtualShop. Without the list, the server refuses purchases when no trader of that shop is nearby.
Yes, with SetItemStock, AddItemStock and TriggerShopRefresh. Add the resource name to Config.AdminExportResources first. Read exports work from any resource. Stock changed by export resets at the next restart, so a delivery job should restock again after a restart.
Updates
- Update ML Bridge first
- Download the latest version from CFX Portal
- Back up
shared/config.lua,server/config_server.luaand theopen/folder - Replace all files except your config and
open/files - Restart the server
Shops, traders, items and stock are stored in the database and stay after an update. New columns are added on start.