Skip to main content
Server Client Proxied to ug-core. Shops sell items for an account. Prices, stock, distance and access are decided on the server. A client only says which item, by its position in the shop, and how many.

Config

config/shops.lua
Items, accounts and metadata are checked when ug-core starts: an unknown item or account stops boot with the shop name. The default config comes with a 24/7 and an Ammu-Nation.

How a purchase works

  1. The player is near one of the shop’s coords, measured on the server, and has access.
  2. There is enough stock, and the items fit in the player’s inventory.
  3. Shops:BeforePurchase allows it. It MAY lower the total, for a discount, never raise it.
  4. The stock is reserved, then the account is charged with reason shop:<name>.
  5. The items are added. If that fails, the account is refunded with reason shop:<name>:refund and the stock returns.
Both the ledger and the item audit log record the purchase. Weapons bought get their serial registered to the buyer.

Server

Buy

MUST run in a thread.
integer
required
Position of the item in the shop’s items.
integer
required
1 to 1,000.

Register

Adds a shop from a resource, with the same fields as the config plus check, a function fun(source): boolean that MUST also pass. Registered shops leave when the resource stops. Their stock stays saved. Config names cannot be registered.

Get / GetAll

stock maps limited items to their current stock.

Restock

Refills limited items to their stock now. Without item, every limited item of the shop.

Client

GetAll reads positions from GlobalState[UgCore.Enums.GlobalState.Shops], for blips and markers. Open and Buy MUST run in a thread.
table
client.lua

Errors

Security

Events

Hooks

Return false to cancel. Return the payload with a lower total for a discount: