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
- The player is near one of the shop’s coords, measured on the server, and has access.
- There is enough stock, and the items fit in the player’s inventory.
Shops:BeforePurchaseallows it. It MAY lower the total, for a discount, never raise it.- The stock is reserved, then the account is charged with reason
shop:<name>. - The items are added. If that fails, the account is refunded with reason
shop:<name>:refundand the stock returns.
Server
Buy
integer
required
Position of the item in the shop’s
items.integer
required
1 to 1,000.
Register
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
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: