Client and security
Client functions and what the server checks on every purchase.
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
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.
Errors
Events
Hooks
Return
false to cancel. Return the payload with a lower total for a discount: