Shops API
Server and client exports for shops. New to shops? Read Shops first.
Finding shops
One shop, by id or by what you hold, as GetVehicle takes a reference.
| Param | Type | Description |
|---|---|---|
| ref | number|table | A shop id, { key = }, or { containerId = } (the shop whose stock that container is) |
table|nil: { shopId, key, name, mode, jobId, containerId, npcModel, prop, x, y, z, heading, blipSprite, blipColor, catalog, settings }local shop = exports.whip_core:GetShop({ key = 'burgershot' })
Every shop, sorted by shopId, or one job's: a job can own several.
| Param | Type | Description |
|---|---|---|
| filter | table? | { job = }, by key or jobId |
table[]; {}, 'No such job' for an unknown jobThe players browsing a shop now.
| Param | Type | Description |
|---|---|---|
| shopId | number | Shop ID |
number[]: sourcesCreating and changing shops
A shop declared by key, safe on every start (example). The same declaration again changes nothing, so an admin's edits stand; a changed one applies your fields and clears a link you dropped (jobId, containerId, npcModel, prop, blipSprite). Another running resource's key is refused.
| Param | Type | Description |
|---|---|---|
| key | string | Stable shop id |
| data | table | { name, mode, npcModel?, prop?, x, y, z, heading, catalog?, jobId?, containerId?, blipSprite?, blipColor?, settings? }; jobId takes a jobId or key |
table: the shop, its declaration in settings.ensured; or false, reason (a bad catalog, no x/y/z, no such job or container, another resource's key, a database error)Open a shop declared by the calling resource for a living, loaded player. Another resource's shop is refused. Purchases keep the shop's normal stock, payment and access checks.
| Param | Type | Description |
|---|---|---|
| source | number | Online player server id |
| ref | number|table | Shop id, { id = n }, { key = 'my_shop' } or { containerId = n } |
| opts | table? | range: metres, default 3, greater than 0 and at most 20. authorize(source): optional server check, must return true; checked again during the session |
A physical shop opens within range of its coordinates. A virtual shop anchors the session at the player's opening position; moving out of range ends access. Validate who may open it in your server handler.
boolean opened, string|nil reasonlocal ok, why = exports.whip_core:OpenShop(source, { key = 'my_shop' }, { range = 3 })
Creates a shop on every call, without a key check: a pop-up stall for one event, say. Fires whip_core:shop:created with { shopId, shop }.
| Param | Type | Description |
|---|---|---|
| data | table | As EnsureShop's |
table: the shop with shopId, or false, reasonChanges the fields you include; false clears jobId, containerId, npcModel, prop, blipSprite or key. Fires whip_core:shop:updated with { shopId, shop }.
| Param | Type | Description |
|---|---|---|
| shopId | number | Shop ID |
| data | table | Shop fields. catalog ({ [itemKey] = price }) replaces an infinite or npc shop's whole catalog; for one price, use AddCatalogItem |
boolean, string|nil: false, 'Shop not found' for an unknown id. Refused for another running resource's shop, as DeleteShopDeletes a shop, closes it for anyone browsing and despawns its entity. Fires whip_core:shop:deleted with { shopId }.
| Param | Type | Description |
|---|---|---|
| shopId | number | Shop ID |
boolean, string|nil: false, 'Shop not found' for an unknown id. Refused for a shop another running resource made or declares; one made in /whip, or whose resource isn't running, is open to anySets a shop's tabs and where its goods sit, as Edit Shelf does for its managers and WHIP's admins. Lower order comes first; unplaced goods follow, A to Z. Both fields can also sit in a shop's settings (config.lua §9, EnsureShop).
| Param | Type | Description |
|---|---|---|
| shopId | number | Shop ID (any mode) |
| categories | string[]? | The tabs in order: 1–24 letters each, at most 12. Omitted: kept |
| layout | table? | { [itemKey] = { category, order } }. Each entry replaces that item's place; one with neither removes it; others keep theirs |
boolean, string|nil: false for an unknown item, a tab the shop doesn't have, a tab name too long or too many tabsVirtual shops
Set settings.virtual = true in EnsureShop, CreateShop or UpdateShop when your resource provides the interaction. WHIP creates no keeper, prop, prompt or blip for it; open it through OpenShop. The shop still needs x/y/z in its declaration and uses the same catalog, stock and payment rules.
Catalog (infinite and npc shops)
An infinite or npc shop's catalog.
| Param | Type | Description |
|---|---|---|
| shopId | number | Shop ID |
table|nil: { [itemKey] = price }, nil for no such shopAdds or reprices one registered item in an infinite or npc shop's catalog, and saves it.
| Param | Type | Description |
|---|---|---|
| shopId | number | Shop ID |
| itemKey | string | Item key |
| price | number | ≥ 0 |
boolean, string|nilRemoves one item from an infinite or npc shop's catalog, and saves it.
| Param | Type | Description |
|---|---|---|
| shopId | number | Shop ID |
| itemKey | string | Item key |
boolean, string|nilStock and prices (stocked shops)
A stocked shop's shelf, each slot with its item's price. Loaded from the database if not cached.
| Param | Type | Description |
|---|---|---|
| shopId | number | A stocked shop |
table: { [slot] = { item, amount, metadata, price, forSale } }, or false, reason (not stocked, no such shop)Every item price a stocked shop has, for sale or not.
| Param | Type | Description |
|---|---|---|
| shopId | number | A stocked shop |
table: { [itemKey] = { price, forSale } }, or false, reason (not stocked, no such shop)Prices an item on a stocked shop's shelf, or takes it off sale. One price per item, for every slot holding it; customers see it at once. Fires whip_core:shop:priceChanged with { containerId, item, price, forSale }.
| Param | Type | Description |
|---|---|---|
| containerId | number|table | The stock container ID, or { shopId = n }, as every shop export takes |
| itemKey | string | A registered item |
| price | number | Dollars (0 = free; negative becomes 0) |
| forSale | boolean | false keeps the price but hides the item |
boolean, string|nil: 'Unknown container', 'Unknown item', 'Invalid price' (not a number)exports.whip_core:SetShopItemPrice({ shopId = shopId }, 'drink', 5, true) -- water at $5
Client#
Whether the shop screen is open.
booleanThe shop the player is browsing, or nil.
number|nil