Skip to content

Shops & crafting ​

Shops ​

Branded shops

For full stores with GTA lore brands, receipts, robberies, player-owned shops and a phone app, use np_shops. It runs on np_inventory and replaces the shops below: while np_shops runs, these built-in shops switch off on their own (np_shops detection).

Shop

At every shop location players get an [E] Shop prompt, and shops with a blip show on the map. The shop screen has a cart: pick items and amounts, then pay with cash or card (bank). Prices, labels, stock, locks and metadata always come from the server config; the client only sends item indexes and amounts.

lua
-- shared/config/shops.lua
Config.Shops[#Config.Shops + 1] = {
  id = 'ammunation', label = 'Ammu-Nation', sublabel = nil, icon = 'gun', tint = 'rust',
  blip = { sprite = 110, color = 1, scale = 0.7 },
  locations = { vec3(-662.18, -934.96, 21.83), vec3(810.25, -2157.60, 29.62) },
  distance = nil,                      -- default Config.ShopDistance (3 m)
  groups = nil,                        -- lock the whole shop to jobs / gangs
  society = nil,                       -- job that gets the money through np_payments, e.g. 'ammunation'
  currency = 'cash',                   -- 'cash' | 'bank' | 'black_money'
  discounts = { police = 25, sheriff = 25 },
  restock = 7200,                      -- seconds; nil = never
  items = {
    { name = 'weapon_knife', price = 120, stock = 15 },
    { name = 'weapon_pistol', price = 2500, stock = 8, license = 'weapon' },
    { name = 'armour_vest', price = 1500, stock = 5, groups = { police = 0, sheriff = 0 } },
  },
}
Shop field Description
id Unique id
label, sublabel, icon, tint Header and prompt
locations Positions (vec3). A shop without locations can only be opened through an export
distance Reach at each location
blip { sprite, color, scale? }
groups Only these jobs / gangs can open the shop
society Job whose society account gets the money. Only used when the purchase goes through np_payments
currency Default currency of the items
discounts [job] = percent off for players with that job. Shown in the header
restock Every this many seconds the stock refills to the configured values
items The goods, in display order
Item field Description
name, price Item and price per unit (whole numbers; 0 is free)
stock Units in stock. nil = unlimited. Persisted in np_inventory_shops
currency Overrides the shop currency for this item
license 'weapon' or 'driver': locked without that licence (qb / qbx metadata licences, esx_license on ESX, np_admin node np_inventory.license.<name> or <name>_license item standalone)
groups Locked for everyone but these jobs / gangs, e.g. { ambulance = 2 }
metadata Metadata for every bought unit

Paying: items priced in cash can be paid with cash or card, the player chooses. bank items always charge the bank, black_money items black money (the item, or the ESX account outside item mode). The discount applies to each currency total, rounded. Before anything is charged the server checks the stock, the space in the pockets and the money; if adding an item still fails after the payment, that line is refunded. Every purchase is logged (buy). An item's ox-style server.export is asked with buying first and can refuse the purchase (Items).

Locked items stay visible with the reason ("Needs a weapon licence"). The shipped shops: a 24/7 at ten locations (EMS get 10 % off), Ammu-Nation at nine (police 25 %), YouTool hardware and an EMS-only pharmacy.

np_payments checkout ​

With np_payments running and Config.Payments = 'auto' (the default), the cash and card totals of a cart become one np_payments checkout. Its sheet opens on top of the shop, and the player can pay from cash or any account they may use: checking, savings, shared, business or faction accounts. Split, tip and pay later are not offered.

  • The sheet lists every item with its base price, and the job discount as a negative line.
  • The shop's Cash / Card choice preselects the account. Carts with bank-priced items exclude cash.
  • The merchant id is np_inventory:shop:<id>, the category shop. The money goes to the shop's society account, or nowhere without one.
  • After the sheet the server checks stock and pocket space again. If the purchase can't complete, or adding an item fails, the money goes back through exports.np_payments:Refund.
  • black_money items are still charged by np_inventory itself. Player trades never use np_payments.
Config.Payments Behaviour
'auto' np_payments while it runs, else the old cash / card path. An error from np_payments also falls back
true Always np_payments. Purchases fail while it isn't running
false Never np_payments

np_shops detection ​

np_inventory detects np_shops and steps aside. With Config.NpShops = 'auto' (the default), while the np_shops resource is started or starting, the shops from shared/config/shops.lua (Config.Shops) are switched off:

  • no [E] Shop prompts and no blips for them,
  • shop:open and shop:buy refuse them with the code shop_disabled ("This shop is closed."), qb OpenShop returns false, and a built-in shop that is open at that moment closes.

You don't have to empty Config.Shops, and a counter never shows two prompts. Shops other resources register at runtime (below: RegisterShop, qb CreateShop, e.g. the fallback shops of np_drugs or np_gangs) stay active, even one that reuses the id of a built-in shop.

The switch is live: np_inventory re-checks when np_shops starts or stops, so the start order doesn't matter and ensure np_shops / stop np_shops at runtime hides or brings back the built-in shops without restarting np_inventory. The console shows one line at start:

[np_inventory] built-in shops: off, np_shops is running
[np_inventory] built-in shops: on
Config.NpShops Behaviour
'auto' Built-in shops off while np_shops runs, on otherwise
true Same as 'auto'
false Never step aside: both shop systems run side by side

To keep your own shop lists, let np_shops take them over with its Config.ImportInventoryShops.

Runtime shops ​

lua
-- ox_inventory signature
exports.np_inventory:RegisterShop('bait_shop', {
  name = 'Bait & Tackle',
  inventory = {
    { name = 'fish', price = 25, count = 50 },
    { name = 'lighter', price = 3, grade = 1 },     -- with groups: minimum grade for this item
  },
  locations = { vec3(-1592.5, 5203.2, 4.3) },
  groups = { fisher = 0 },
})

-- qb-inventory signature (qb-shops calls these)
exports['qb-inventory']:CreateShop({ name = 'bait_shop', label = 'Bait & Tackle', coords = vec3(…), items = { … } })
exports['qb-inventory']:OpenShop(source, 'bait_shop')

Shops registered with RegisterShop are announced to every client (and to players who join later), so their locations get prompts like config shops. Runtime shops are not switched off while np_shops runs. OpenShop opens a shop on the server once the player stands at one of its locations.

Open a shop from a client script:

lua
exports.np_inventory:openInventory('shop', { type = 'ammunation', id = 1 })   -- id = location index (optional)

Crafting ​

Crafting bench

At a bench players get [E] Craft. The crafting screen lists the recipes with their ingredients (and where they come from), locks and chances; players queue up to 10 crafts at a time.

lua
-- shared/config/crafting.lua
Config.Crafting[#Config.Crafting + 1] = {
  id = 'mirrorpark', label = 'Workbench', sublabel = 'Garage Mirror Park',
  coords = vec3(1178.43, -322.31, 69.18), radius = 2.0,
  groups = nil,                                          -- lock the bench to jobs / gangs
  storage = { slots = 30, maxWeight = 150000 },          -- or true (30 slots / 150 kg)
  skill = { name = 'mechanic', label = 'Mechanics' },    -- shown in the header with the player's level
  recipes = {
    {
      id = 'repairkit', name = 'repairkit', count = 1, duration = 45000, category = 'tool',
      ingredients = { steel = 2, plastic = 2, wire = 3, toolbox = { count = 1, keep = true } },
      requires = { job = 'mechanic', skill = 'mechanic', level = 3 },
      chance = { quality = 4, percent = 8 },
    },
  },
}
Bench field Description
id, label, sublabel Id and header
coords, radius Position and reach (default Config.CraftingDistance, 2.5 m)
groups Only these jobs / gangs can use the bench
storage A shared bench stash, stash:bench:<id>. Ingredients are also taken from it
skill { name, label } shown in the header
recipes The recipes, in display order
Recipe field Description
id Unique per bench (default: name)
name, count Output item and amount per craft
duration ms per craft
category Filter tab (default: the output item's category)
metadata Metadata of the output
ingredients { item = n }, or { item = { count = n, keep = true } } for tools that must be there but aren't used up
requires { job?, grade?, skill?, level? }. The recipe shows locked with the reason until it's met
chance { quality = 1..5, percent }: rolled per craft when it's queued; a hit sets metadata.quality on the output

How it works:

  • Ingredients are taken from the pockets first, then the equipped bag, then the bench storage.
  • Storage: benches with storage show a Storage button (key L) in the header. It closes the bench and opens the inventory with the bench stash next to the pockets (same reach and groups as the bench). They are consumed when a craft is queued, per queued craft.
  • The queue runs on server time and keeps running while the player is away or offline. It is stored per character and bench in np_inventory_crafting. Up to Config.CraftingQueueMax (10) entries per bench; one start adds 1–10.
  • Cancel a craft that hasn't finished and get back exactly what it consumed, with the items' own durability, freshness and serials: into the pockets, else the bench storage, else a drop at the bench.
  • Collect takes every finished craft into the pockets, as far as they fit.
  • Skills come from Config.Skills.get(src, name) when you set it (any skill resource), else from the framework: metadata.skills[name] (a number or { level }) on qb / qbx. On ESX and standalone without get, skill requirements and the skill header are skipped, so those recipes aren't locked forever.
  • beforeCraft hooks can veto a craft; crafts are logged at start and collect (craft).

Open a bench from a client script with exports.np_inventory:openInventory('crafting', 'mirrorpark').