DND Docs

Resourcesdnd_economyReference

Exports & Events

Last updated on

Exports dnd_economy provides

Open, unauthenticated read-only market data (integrations/exports.lua) — the same data /demarket already shows any player in-game, filtered per-agency by publicStock.

-- Full market overview, every agency.
local overview = exports.dnd_economy:GetMarketOverview()
-- { agencies = { { id, label, items = {...}, ... }, ... }, generatedAt }

-- A single agency's items only.
local result = exports.dnd_economy:GetAgencyMarket('disnaker')
-- { success = true, agency = {...}, generatedAt } or { success = false, reason = 'not_found' }

Events dnd_economy fires

AddEventHandler('dnd_economy:purchaseCompleted', function(order)
    -- order = {
    --   agencyId, items = { { itemName, itemLabel, quantity, pricePerUnit, total, ... }, ... },
    --   total, buyerIdentifier, buyerName, handlerIdentifier, handlerName, timestamp,
    -- }
end)

Fires once per accepted Buy cart (not once per line item) after HybridBuy.Accept successfully executes every line.

Consuming dnd_jobmanagement's purchase-document export

If Config.Printer = 'dnd_jobmanagement', dnd_economy calls this itself at accept time — you don't need to call it yourself unless you're building your own integration:

local ok, requestId = exports['dnd_jobmanagement']:CreatePurchaseDocument({
    issuerSource = handlerSource,      -- staff who accepted the order
    agencyLabel = 'Government Agency',
    agencyJobName = 'government',      -- gates who can print it — see dnd_jobmanagement's Config.JobAliases
    buyerIdentifier = 'ABC123',
    buyerName = 'John Doe',
    buyerJobLabel = 'Mechanic',        -- optional, shown next to "Instansi" on the document
    priceMode = 'instansi' | 'gang',
    items = { { itemLabel, quantity, pricePerUnit, lineTotal, pricePerUnitFormatted, lineTotalFormatted }, ... },
    total = 4200,
    totalFormatted = '$4,200', -- optional; falls back to '$'..total
})

ok == true on success, with requestId usable at any dnd_jobmanagement printer prop by staff on the agency's job (or government). This requires dnd_jobmanagement to be running — the call is wrapped in pcall on the dnd_economy side, so a missing/offline dnd_jobmanagement doesn't unwind an already-completed sale, it just skips the document and logs a warning.

Consuming dnd_phone's bank-history export

On every bank-settled Buy or Sell, dnd_economy calls this itself so the transaction appears in the player's mBanking → History — you don't need to call it yourself unless you're building your own integration:

local ok = exports.dnd_phone:RecordBankHistory(
    source,        -- the player's server id (used to read their live balance for balance_after)
    identifier,    -- their framework identifier (citizenid/license)
    amount,        -- positive integer
    description,   -- shown in the phone's history list, e.g. "Bought 5x Steel from Ammunation"
    direction      -- 'in' (renders green/incoming) or 'out' (renders red/outgoing)
)

Requires dnd_phone to be running and the player to have a registered phone device — both cases just no-op (ok == false) rather than error. dnd_economy's own call is wrapped in pcall plus a GetResourceState('dnd_phone') check, so a missing/offline dnd_phone never unwinds an already-completed transaction.

On this page