βš™οΈConcepts & How It Works

This guide shows how to create and reuse shop themes in MarketV2. Define visuals (NPC/blip/marker/UI), payments, access rules, and full item catalogs, then style the UI via CSS theme tokens

πŸ“š RISK MARKET V2 β€” SHOPS & THEMES

Note: This script receives regular updates with new features and improvements. This documentation may not reflect the latest version. Always refer to the most recent configuration files, example configs, and release notes included with your script version for accurate and up-to-date information.


1) Overview

  • Shops are world instances you place (in Config.MarketShops, WeaponShops, BlackMarkets, JobShops).

  • Each shop points to a theme: Config.MarketThemes[THEME_KEY].

  • A theme defines visuals (NPC/blip/marker/UI colors), economy (payments), access, and the catalog (categories + items).


2) Theme Anatomy

Define under Config.MarketThemes:

Config.MarketThemes = Config.MarketThemes or {}

Config.MarketThemes.mytheme = {
  distance = 3.0,
  npc   = { enabled = true, model = 'a_m_y_business_01' },
  blip  = { enabled = true, sprite = 52, color = 48, scale = 0.8, name = 'My Themed Shop' },
  marker= { enabled = true, type = 29, scale = 0.5, color = { r=255,g=255,b=0,a=150 } },

  ui = {
    title = 'MY THEME',
    description = 'Welcome!',
    showStock = true  -- show stock to customers on owned shops
  },

  payment = {
    cash = true, 
    bank = true, 
    blackmoney = false
    -- itemCurrency = { enabled = true, item = 'gold_token', per = 100 }
  },

  -- Optional access control (jobs/grades):
  access = {
    jobs = 'all',  -- or { 'police','ambulance' }
    minGrade = 0,
    minGrades = { police = 3 }
  },

  weaponsAsItems = false, -- false=give to loadout, true=inventory item

  -- Optional per-job category gates:
  -- categoryAccess = {
  --   police = { { minGrade = 2, categories = { 'Restricted' } } }
  -- },

  categories = {
    { name = 'Snacks', icon = 'img/items/hamburger.png' },
    -- { name = 'Restricted', icon = 'img/categories/crown.png' }
  },

  items = {
    Snacks = {
      { name='bread',     label='Bread',     price={min=10,max=15}, image='img/items/bread.png',     description='Fresh loaf.' },
      { name='hamburger', label='Hamburger', price={min=25,max=25}, image='img/items/hamburger.png', description='Juicy & quick.' }
    }
    -- Restricted = { ... }
  }
}

Rules

  • Category names in items must match categories.

  • price can be a number (price=100) or {min,max}.

  • image can be img/... (NUI) or https://....


3) Attach Theme to a Shop

  • IDs must be unique across all shops.

  • Switch look/catalog by changing theme.

  • NEW: Each shop can have its own license requirements via the license table.


4) License System (NEW)

Per-Shop License Configuration

Each shop can require a license. Configure in the shop's coords:

License Modes

Mode
Description
Required Config

'item'

Player must have item in inventory

itemName = 'weapon_license'

'esx'

ESX license system check

esxType = 'weapon'

'tkmdt'

TK-MDT license system

tkmdtType = 'weapon' / 'pistol' / 'rifle'

Example: Weapon Shop with License

Example: TK-MDT Pistol Shop

TK-MDT Configuration

Enable/disable TK-MDT weapon registration globally:

License Notifications

When a player lacks a license, they receive a notification:

  • ❌ You need a valid license


5) UI Styling (CSS)

Frontend adds theme-<key> on <body>. Define colors in html/css/config.css:


6) Payments

Toggle cash, bank, blackmoney in payment.

Item Currency

QBCore Black Money as Item


7) Ownership, Pricing & Stock

Unowned Shops

  • Prices read from theme each open (min..max random if range).

  • No DB stock tracking.

Owned Shops

  • Prices freeze to DB on purchase (owner can edit).

  • Stock tracked per item (show in UI if ui.showStock=true).

  • Sales credit shop balance; purchases decrement stock.


8) Access Control & Weapons

Restrict by job/grade via access (and optionally categoryAccess).

Job/Grade Access (Theme Level)

Weapons

  • weaponsAsItems=false β†’ given to loadout (duplicates blocked).

  • weaponsAsItems=true β†’ added as inventory items.


9) Delivery Missions (Owner Restock)

Start from owner UI β†’ server calls:

Flow

  1. Truck spawns at Config.Delivery.Spawns[shopId].spawn.

  2. Load at loadMarker (progress bar).

  3. Return to shop and unload β†’ stock increases.

Configuration


10) Owner Flow (Bank & Procurement)

  • Buy: Charge bank; create risk_mv2_balances row; freeze prices; init stock rows.

  • Fund/Withdraw: Bank ↔ shop balance (fee via Config.FundFeePercent).

  • Set Price: DB update + live NUI refresh.

  • Procure: Buy stock from balance at wholesale = min(price) * (1 - Discount%).


11) Exports & Events

Server Exports

Core Events

  • risk_markets:open β†’ Open UI for shop id (server).

  • risk_markets:purchase β†’ Process cart/payment (server).

Owner Actions

  • risk-mv2a:setItemPrice

  • risk-mv2a:fundAccount

  • risk-mv2a:withdrawAccount

  • risk-mv2a:procureItem

Delivery Flow

  • risk-markets:delivery:* (spawn/load/unload/done)


12) Images & Paths

  • Prefer local img/... under the resource's html folder.

  • Remote images: full https://....

  • If you rename the resource, update any nui://<resource>/... paths used elsewhere.


13) ox_target vs. Markers

  • If Config.UseOxTarget = true and ox_target is running β†’ NPC/box-zone context options.

  • Otherwise β†’ 3D marker + "E" prompt.


14) Best Practices

βœ… Keep catalog & visuals in themes; reuse themes across many shops. βœ… Ensure unique shop IDs. βœ… Show stock to players only where meaningful (ui.showStock=true). βœ… Start access simple (jobs='all'), add minGrade/categoryAccess later. βœ… Use per-shop license config for flexible access control. βœ… Test license modes thoroughly before production.


15) Gotchas & Troubleshooting

❌ Duplicate IDs: Don't reuse (e.g., 247_2 twice) β€” rename one (e.g., 247_4). ❌ UI won't open: Check ox_target state or stand in marker and press E. ❌ Images missing: Bad path; verify relative to html or use https://. ❌ Prices not persistent: Only persist after ownership (unowned uses theme config). ❌ Stock not changing: Tracked only for owned shops. ❌ License not working: Verify license.required = true and correct mode settings. ❌ No license notification: Check server console for errors in license checks.


16) Minimal Example Theme + Shop

Theme

CSS

Shop


17) Weapon Shop License Examples

Example 1: Basic Weapon Shop (Item License)

Example 2: Pistol Shop (TK-MDT)

Example 3: Rifle Shop (ESX)

Example 4: No License Shop


Last updated