Flake Shops
A dynamic, database-driven shop system for FiveM. Build and manage custom shops entirely in-game with dual ESX & QB-Core support, multi-currency, pickup mechanics, shop peds, map blips, analytics, and Discord logging.
Overview
Flake Shops is a fully dynamic shop resource that lets server owners and admins create, edit, and delete shops entirely from within the game — no config file editing required. Every shop is stored in MySQL and pushed to all connected clients in real time, meaning changes take effect immediately without a resource restart.
The script detects your framework automatically and bridges item purchases through ESX or QB-Core. It supports multi-currency transactions (cash, bank, or black-money), optional pickup mechanics that spawn a ped and a timed blip, shop NPCs, and full map blip support. Analytics tables record visits, purchases, popular items, and daily revenue for server-side reporting.
Features
- •Dual Framework Support — Auto-detects ESX or QB-Core with no manual configuration.
- •In-Game Creator — Use /shopscreator to open a full create/edit/delete admin UI without touching any files.
- •Database Driven — All shop data is persisted in MySQL and broadcast to clients on demand.
- •Multi-Currency — Charge purchases in cash, bank, or black-money on a per-shop or per-item basis.
- •Pickup System — Optional delivery mechanic — items are collected from a timed blip location instead of handed directly.
- •Shop Peds — Attach an NPC ped to any shop for immersive storefront presentation.
- •Map Blips — Each shop can display a labelled blip on the map for easy navigation.
- •Analytics — Optional tables track visits, purchases, popular items, and daily revenue.
- •Discord Logging — Purchase and admin events are forwarded to a configurable Discord webhook.
- •Custom UI — Fully styled HTML/CSS shop interface with item previews and quantity selectors.
Requirements
| Dependency | Purpose | Required |
|---|---|---|
mysql-async | MySQL wrapper for shop data persistence | Yes |
| ESX or QB-Core | Framework for players, inventories, and currency | Yes |
| OX Inventory or QB-Inventory | Item storage and image rendering | Yes |
ox_lib | TextUI prompts during pickup interactions | No |
Framework Detection
Config.Framework flag is required — simply ensure either es_extended or qb-core is started before flake_shops.Installation
Step 1 — Ensure the Resource
Place the flake_shops folder in your resources directory and add the following line to server.cfg:
ensure flake_shopsStep 2 — Import the Core SQL
Run the following SQL in your database to create the main shops table:
CREATE TABLE IF NOT EXISTS `shops` (
`id` INT NOT NULL AUTO_INCREMENT,
`shop_name` VARCHAR(100) NOT NULL,
`shop_data` LONGTEXT NOT NULL,
`created_at` TIMESTAMP DEFAULT CURRENT_TIMESTAMP,
`updated_at` TIMESTAMP DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP,
PRIMARY KEY (`id`)
);Step 3 — Import Analytics Tables (Optional)
These tables are optional but enable the analytics dashboard. Import them only if you intend to use the reporting features:
CREATE TABLE IF NOT EXISTS `shop_visits` (
`id` INT NOT NULL AUTO_INCREMENT,
`shop_id` INT NOT NULL,
`identifier` VARCHAR(60),
`visited_at` TIMESTAMP DEFAULT CURRENT_TIMESTAMP,
PRIMARY KEY (`id`)
);
CREATE TABLE IF NOT EXISTS `shop_purchases` (
`id` INT NOT NULL AUTO_INCREMENT,
`shop_id` INT NOT NULL,
`identifier` VARCHAR(60),
`item` VARCHAR(80),
`quantity` INT DEFAULT 1,
`price` INT DEFAULT 0,
`purchased_at` TIMESTAMP DEFAULT CURRENT_TIMESTAMP,
PRIMARY KEY (`id`)
);
CREATE TABLE IF NOT EXISTS `shop_popular_items` (
`item` VARCHAR(80) NOT NULL,
`total_sold` INT DEFAULT 0,
PRIMARY KEY (`item`)
);
CREATE TABLE IF NOT EXISTS `shop_daily_revenue` (
`date` DATE NOT NULL,
`revenue` INT DEFAULT 0,
PRIMARY KEY (`date`)
);Step 4 — Edit the Config
Open config/config.lua and adjust debug mode, UI colour, admin groups, draw distance, inventory image URLs, currency, and pickup settings to match your server. See the Configuration section for all available keys.
File Structure
flake_shops/ ├── client/ │ ├── main.lua -- Shop UI, blips, peds, pickup flow │ └── creator.lua -- In-game creator panel client logic ├── server/ │ ├── main.lua -- Purchases, DB reads/writes, Discord logs │ └── analytics.lua -- Visit & revenue tracking ├── config/ │ └── config.lua -- All tunables (escrow-ignored) ├── html/ │ ├── index.html -- Shop UI entry point │ ├── style.css -- UI styles │ └── script.js -- UI logic and NUI messaging └── fxmanifest.lua -- Resource manifest
Ready to Go
/shopscreator in-game to create your first shop — no restart needed.Configuration
All settings live in config/config.lua. This file is escrow-ignored and safe to edit freely.
Core Settings
| Key | Default | Description |
|---|---|---|
Config.Debug | false | Print debug output to the server console |
Config.UiColor | "#3b82f6" | Primary accent colour used throughout the shop UI |
Config.AdminGroups | { "admin", "superadmin" } | ESX groups (or QB permissions) allowed to open /shopscreator |
Config.DrawDistance | 10.0 | Distance in metres at which shop peds and blips become interactive |
Config.InventoryImgUrl | "nui://ox_inventory/web/build/images/" | Base URL for item thumbnail images in the shop UI |
Currency Config
Each shop and each item can specify a payment method. The supported values are:
- •
cash— deducted from the player's on-hand cash balance. - •
bank— deducted from the player's bank account. - •
black_money— deducted from the player's dirty money balance (ESX) or marked money (QB).
Per-Item Override
Pickup Config
| Key | Default | Description |
|---|---|---|
Config.UsePickup | false | Enable the pickup delivery mechanic for shops that opt in |
Config.PickupRadius | 200.0 | Maximum metres from the shop at which a pickup location may spawn |
Config.PickupWaitTime | 120 | Seconds the pickup blip stays active before expiring |
Config.PickupPedModel | "a_m_y_acult_01" | Ped model spawned at the pickup location |
Config.PickupBlipSprite | 521 | GTA V blip sprite ID for the pickup marker |
Config.PickupBlipColor | 2 | GTA V blip colour index for the pickup marker |
Pickup System
When Config.UsePickupis enabled on a shop, purchased items are not delivered to the player's inventory immediately. Instead, they trigger a timed delivery event:
- 1Purchase Confirmed — The server validates payment and triggers the pickup flow instead of awarding items directly.
- 2Random Location Chosen — A random coordinate within Config.PickupRadius of the shop origin is selected server-side.
- 3Blip Spawned — The client receives the location and spawns a temporary blip on the player's map (PickupBlipSprite / PickupBlipColor).
- 4Timer Starts — The player has Config.PickupWaitTime seconds to reach the location before the pickup expires.
- 5Ped Spawns — On arrival, a ped (Config.PickupPedModel) spawns at the exact coordinate holding the order.
- 6Items Collected — The player interacts with the ped via ox_lib TextUI. On confirm, items are added to inventory and the ped and blip are cleaned up.
Pickup Expiry
Config.PickupWaitTimeseconds, the blip is removed and items are forfeited. Currency is still deducted. Consider setting an appropriate timer based on your server's map size.ox_lib Dependency
ox_lib for TextUI. If you do not have ox_lib, either disable the pickup system or replace the TextUI call in client/main.lua with your preferred prompt resource.Admin Panel
Flake Shops ships with a full in-game admin creator so shops can be built and managed without editing any files. Access is gated by the groups listed in Config.AdminGroups.
Opening the Creator
Type /shopscreator in chat. The UI opens as an overlay on the current camera position. From here you can:
- •Create a new shop — set name, location, ped model, blip, currency, items, and pickup toggle.
- •Edit an existing shop — modify any property and save back to the database instantly.
- •Delete a shop — removes the record from MySQL and de-spawns all associated peds and blips for every connected client.
Admin Commands
| Command | Description | Permission Required |
|---|---|---|
/shopscreator | Open the in-game shop creator/editor panel | Admin |
/listshops | Print a list of all shops and their IDs to your chat | Admin |
/gotoshop [id] | Teleport to the spawn coordinates of the specified shop | Admin |
Permission Check
Config.AdminGroups receive a denied notification and the command has no effect.Events
The following events are used internally and can be listened to for custom integrations. All events are prefixed with flake_shops:.
Client Events
| Event | Payload | Description |
|---|---|---|
updateShops | shops (table) | Fired when the shop list is refreshed from the server. Triggers ped and blip re-spawn. |
createPickupBlip | coords (vector3), expiry (number) | Creates the timed pickup blip on the client map. |
pickupReady | coords (vector3), items (table) | Signals that the delivery ped has spawned and items are ready to collect. |
notify | message (string), type (string) | Displays a notification to the player (success / error / info). |
Server Events
| Event | Payload | Description |
|---|---|---|
requestShops | — | Client requests the full shop list. Server responds with updateShops. |
buyItems | shopId (number), items (table) | Validates payment and either awards items or initiates the pickup flow. |
pickupItems | pickupId (string) | Confirms item collection at the pickup location and cleans up the ped/blip. |
Event Security
buyItems or pickupItems from client-side without going through the provided NUI callbacks. All currency checks and inventory writes are done server-side.Commands
| Command | Arguments | Description |
|---|---|---|
/shopscreator | — | Open the in-game admin shop creator panel |
/listshops | — | List all shops and their database IDs in chat |
/gotoshop | [id] | Teleport to the coordinate of the specified shop ID |
Troubleshooting
| Issue | Fix |
|---|---|
| Shop UI does not open | Ensure flake_shops is started after your framework and that NUI focus is not blocked by another resource. |
| Items not appearing in shop | Confirm the item names in the creator match your inventory exactly — item names are case-sensitive. |
| Images not showing in UI | Verify Config.InventoryImgUrl points to the correct path for your inventory resource. |
| Cannot afford / wrong currency | Check the currency type set per-shop in the creator. Ensure the player has funds in the selected account (cash / bank / black_money). |
| Pickup blip does not appear | Confirm Config.UsePickup is true for the shop and that ox_lib is started. |
| /shopscreator denied | Verify your in-game group is listed in Config.AdminGroups (ESX) or that you have the correct QB permission. |
| Database error on startup | Ensure mysql-async (or oxmysql) is started before flake_shops in server.cfg and the SQL schema has been imported. |
| Peds / blips not spawning | Run /listshops to confirm shops are in the database. If empty, shops may not have saved correctly — check server console for SQL errors. |
Developed by Flake Development. For support, open a ticket in our Discord.
