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.

FiveMESX & QB-CoreMySQLLua 5.4
Purchase Script
flakedev.com

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 SupportAuto-detects ESX or QB-Core with no manual configuration.
  • In-Game CreatorUse /shopscreator to open a full create/edit/delete admin UI without touching any files.
  • Database DrivenAll shop data is persisted in MySQL and broadcast to clients on demand.
  • Multi-CurrencyCharge purchases in cash, bank, or black-money on a per-shop or per-item basis.
  • Pickup SystemOptional delivery mechanic — items are collected from a timed blip location instead of handed directly.
  • Shop PedsAttach an NPC ped to any shop for immersive storefront presentation.
  • Map BlipsEach shop can display a labelled blip on the map for easy navigation.
  • AnalyticsOptional tables track visits, purchases, popular items, and daily revenue.
  • Discord LoggingPurchase and admin events are forwarded to a configurable Discord webhook.
  • Custom UIFully styled HTML/CSS shop interface with item previews and quantity selectors.

Requirements

DependencyPurposeRequired
mysql-asyncMySQL wrapper for shop data persistenceYes
ESX or QB-CoreFramework for players, inventories, and currencyYes
OX Inventory or QB-InventoryItem storage and image renderingYes
ox_libTextUI prompts during pickup interactionsNo

Framework Detection

The script detects your framework on startup. No 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:

server.cfg
ensure flake_shops

Step 2 — Import the Core SQL

Run the following SQL in your database to create the main shops table:

flake_shops.sql
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:

flake_shops_analytics.sql
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

After importing SQL and ensuring the resource, start your server. Use /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

KeyDefaultDescription
Config.DebugfalsePrint 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.DrawDistance10.0Distance 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

Currency is set at the shop level by default. Individual items in the creator can override the shop currency if your server needs mixed-payment shops.

Pickup Config

KeyDefaultDescription
Config.UsePickupfalseEnable the pickup delivery mechanic for shops that opt in
Config.PickupRadius200.0Maximum metres from the shop at which a pickup location may spawn
Config.PickupWaitTime120Seconds the pickup blip stays active before expiring
Config.PickupPedModel"a_m_y_acult_01"Ped model spawned at the pickup location
Config.PickupBlipSprite521GTA V blip sprite ID for the pickup marker
Config.PickupBlipColor2GTA 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:

  1. 1Purchase ConfirmedThe server validates payment and triggers the pickup flow instead of awarding items directly.
  2. 2Random Location ChosenA random coordinate within Config.PickupRadius of the shop origin is selected server-side.
  3. 3Blip SpawnedThe client receives the location and spawns a temporary blip on the player's map (PickupBlipSprite / PickupBlipColor).
  4. 4Timer StartsThe player has Config.PickupWaitTime seconds to reach the location before the pickup expires.
  5. 5Ped SpawnsOn arrival, a ped (Config.PickupPedModel) spawns at the exact coordinate holding the order.
  6. 6Items CollectedThe 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

If the player does not reach the pickup location within 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

The pickup interaction prompt requires 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

CommandDescriptionPermission Required
/shopscreatorOpen the in-game shop creator/editor panelAdmin
/listshopsPrint a list of all shops and their IDs to your chatAdmin
/gotoshop [id]Teleport to the spawn coordinates of the specified shopAdmin

Permission Check

Commands perform a server-side group check. Players not in 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

EventPayloadDescription
updateShopsshops (table)Fired when the shop list is refreshed from the server. Triggers ped and blip re-spawn.
createPickupBlipcoords (vector3), expiry (number)Creates the timed pickup blip on the client map.
pickupReadycoords (vector3), items (table)Signals that the delivery ped has spawned and items are ready to collect.
notifymessage (string), type (string)Displays a notification to the player (success / error / info).

Server Events

EventPayloadDescription
requestShopsClient requests the full shop list. Server responds with updateShops.
buyItemsshopId (number), items (table)Validates payment and either awards items or initiates the pickup flow.
pickupItemspickupId (string)Confirms item collection at the pickup location and cleans up the ped/blip.

Event Security

Never trigger buyItems or pickupItems from client-side without going through the provided NUI callbacks. All currency checks and inventory writes are done server-side.

Commands

CommandArgumentsDescription
/shopscreatorOpen the in-game admin shop creator panel
/listshopsList all shops and their database IDs in chat
/gotoshop[id]Teleport to the coordinate of the specified shop ID

Troubleshooting

IssueFix
Shop UI does not openEnsure flake_shops is started after your framework and that NUI focus is not blocked by another resource.
Items not appearing in shopConfirm the item names in the creator match your inventory exactly — item names are case-sensitive.
Images not showing in UIVerify Config.InventoryImgUrl points to the correct path for your inventory resource.
Cannot afford / wrong currencyCheck 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 appearConfirm Config.UsePickup is true for the shop and that ox_lib is started.
/shopscreator deniedVerify your in-game group is listed in Config.AdminGroups (ESX) or that you have the correct QB permission.
Database error on startupEnsure mysql-async (or oxmysql) is started before flake_shops in server.cfg and the SQL schema has been imported.
Peds / blips not spawningRun /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.