For the complete documentation index, see llms.txt. This page is also available as Markdown.

Overview

How categories & rewards work

This page explains the model behind the shop: how a category becomes a set of products, and how buying one actually delivers something to the player.

The three pieces of a category

A working category needs three things:

  1. A config entry in Config.Categories (name + label) so the shop knows the category exists.

  2. Products in the vip_products table (added from the admin panel).

  3. A reward handler registered with RegisterReward so the server knows how to deliver the products in that category.

If any of the three is missing, the category won't work: no config = it won't show; no products = it's empty; no handler = purchases fail with a delivery error.

The reward pipeline

Every purchase and gift runs through a single hardened pipeline on the server (in the escrow‑protected core). In order:

  1. Validate — the product exists, isn't a web link, the buyer meets the VIP requirement, and the buyer has enough of the right currency.

  2. Reserve stock — stock is decremented atomically in the database (stock ≥ 9999 means unlimited and is never decremented). A per‑player lock prevents double‑spends.

  3. Deliver — your category's reward handler runs inside a protected call.

  4. Settle — only if delivery succeeds, the buyer is charged, the purchase is logged, notifications are sent, and the token/category state is refreshed.

The reward handler contract

A handler is a function you register for a category. It receives a single payload table and returns whether delivery succeeded:

Where handlers live

The default handlers ship in server/editable/_<category>.lua (for example _vehicles.lua, _items.lua, _money.lua, _vip.lua, _business.lua, _peds.lua, _weapons.lua). These files are meant to be customized for your framework — they contain the actual database inserts, item grants and money calls. Editable helpers you'll reuse (like generatePlate, getMoney, Round) live in server/editable/functions.lua and server/editable/buy.lua.

Keep your credential/delivery logic in the editable files and let the escrow‑protected core handle the pipeline. That way you can adapt AV VIP to any framework without touching the secure logic.

Last updated