Docs
Money & Items
Charge players and grant items without breaking the economy.
Money first checklist
- Validate
sourceand action on the server. - Check balance /
CanCarrybefore mutating. - Mutate money, then items (or reverse with refunds).
- Notify the client of the outcome.
Example shop
lua
RegisterNetEvent('shop:server:purchase', function(item, count)
local src = source
count = math.floor(tonumber(count) or 0)
if count < 1 or count > 20 then return end
local priceEach = Config.Prices[item]
if not priceEach then return end
local total = priceEach * count
if not Atlas.Inventory.CanCarry(src, item, count).ok then return end
if not Atlas.Money.Remove(src, 'cash', total) then return end
local added = Atlas.Inventory.Add(src, item, count)
if not added.ok then
Atlas.Money.Add(src, 'cash', total)
end
end)Inventory result shape
Always branch on ok:
lua
local r = Atlas.Inventory.Remove(src, 'lockpick', 1)
if not r.ok then
-- r.error
endStatus drain example
lua
Atlas.Status.Add(src, 'hunger', -15)
Atlas.Status.Add(src, 'thirst', -10)
Atlas.Status.Save(src)
Atlas