API Reference

Exports, events, hooks, and callbacks for connecting other resources to Oxide 3D Weapon Printing.

This page is for developers who want to connect other resources to weapon printing. Server owners don't need it to run the resource.

Overview

The supported integration points are:

  • the server exports GiveBlueprintUsb and GetBlueprints, and the matching giveBlueprintUsb server event
  • the server exports GetSetting and SetSetting, for the settings edited in /weaponprinting settings
  • the server events below (blueprintGiven, levelUp, progressionGranted, weaponSold, seized, printStarted, settingsReady)
  • the client events that open the Gunsmith profile
  • reading progression from character metadata
  • recognizing printed weapons, parts and USBs by their item metadata
  • reading a printer's state bag (read-only)

There are no client exports. The callbacks and net events further down are listed for reference only; they are internal, checked and rate-limited on the server, and should not be called by other resources.

Blueprint USBs from Other Resources

Dealers, heists and loot tables hand out blueprint USBs through a server export or a server event (never a net event: clients can't reach it). The USB is the permanent one (printer_usb) or, with once = true, the one-time one (printer_usb_once).

GiveBlueprintUsb

Hands a player a USB carrying a blueprint.

-- From any server resource
local given = exports['oxide-weaponprinting']:GiveBlueprintUsb(source, 'carbine_rifle', false)  -- permanent
exports['oxide-weaponprinting']:GiveBlueprintUsb(source, 'micro_smg', true)                    -- one-time

Parameters:

NameTypeDescription
srcnumberThe player's server ID
blueprintstringA Config.Blueprints or Config.ItemPrints key ('pistol', 'suppressor', 'finish_gold' ...)
onceboolean (optional)true for the one-time USB, otherwise the permanent one

Returns: boolean - true when the USB was given; false for an unknown key, an offline player or a full inventory.


GetBlueprints

Every blueprint the resource knows, by key — useful for building a dealer's stock.

local blueprints = exports['oxide-weaponprinting']:GetBlueprints()
for key, bp in pairs(blueprints) do
    print(key, bp.label, bp.class, bp.level, bp.kind)
end

Returns: table - { [key] = { label, class, level, kind } }. class is the weapon class (pistol, smg, shotgun, rifle, sniper, mg, other, or item for item prints), level the printing level it opens at, and kind is 'weapon' or 'item'.


giveBlueprintUsb (server event)

The same as the export, as a server-only event:

-- From any server script
TriggerEvent('oxide-weaponprinting:server:giveBlueprintUsb', source, 'pistol', true)
NameTypeDescription
srcnumberThe player's server ID
blueprintstringA Config.Blueprints or Config.ItemPrints key
onceboolean (optional)true for the one-time USB

Both the export and the event fire blueprintGiven.

Server Events to Listen For

Fired with TriggerEvent on the server, for other server resources. Listen with AddEventHandler in a server script.

EventArgsWhen
oxide-weaponprinting:server:blueprintGivensrc, blueprint, once, fromA USB was handed out by the export or event (from is the calling resource's name), the dark web ('darkweb'), the store ('store'), a milestone ('milestone') or an admin command ('admin': /weaponprinting kit, giveusb and giveusbonce)
oxide-weaponprinting:server:levelUpsrc, level, previousA player reached a new level by earning XP, or an admin raised it (/weaponprinting setlevel or setxp)
oxide-weaponprinting:server:progressionGrantedsrc, key, xpA player was paid for an action: key is usbLoaded, printCollected, failureFixed, assembled (a weapon), itemBuilt (an item put together at the bench from printed parts), attachmentFitted or sold. xp is the total paid with it, including mastery, goals and milestones (it can be 0)
oxide-weaponprinting:server:weaponSoldsrc, saleA printed weapon was sold to a buyer. sale = { weapon, weaponClass, quality, attachments, finish, price, buyer, maker, printedBy } (attachments is how many it had, finish whether it had one)
oxide-weaponprinting:server:seizedofficerSrc, kind, id, ownerCharId, evidencePolice seized placed equipment. kind is printer, bench or recycler; evidence lists what the equipment held as { item, count, metadata } rows (empty for benches and recyclers, and when Config.Seizure.evidence is off)
oxide-weaponprinting:server:printStartedprinterId, dataA queued part started printing. See Server Hooks
oxide-weaponprinting:server:settingsReady—Fired once, when the settings have loaded from the database. GetSetting returns the saved values from then on. See Reading and Changing Settings
AddEventHandler('oxide-weaponprinting:server:seized', function(officer, kind, id, ownerCharId, evidence)
    print(('%s %s of %s seized by %s (%d evidence rows)'):format(kind, id, tostring(ownerCharId), officer, #evidence))
end)

Client Events for Other Resources

Local client events (TriggerEvent / AddEventHandler on the client):

EventArgsDescription
oxide-weaponprinting:client:openProfilefrom?Opens the Gunsmith profile. from is any string; it's handed back when the profile closes
oxide-weaponprinting:client:profileClosedfromThe profile closed. from is what was passed to openProfile
-- Client: open the profile from your own menu, and come back to it afterwards
TriggerEvent('oxide-weaponprinting:client:openProfile', 'my-menu')

AddEventHandler('oxide-weaponprinting:client:profileClosed', function(from)
    if from == 'my-menu' then
        -- reopen your menu here
    end
end)

Reading a Player's Printing Progression

Progression is stored in character metadata under the weaponprinting key (Config.Progression.metadataKey) via o-link:

-- From any server resource that uses o-link
local data = olink.character.GetMetadata(source, 'weaponprinting')
if data then
    print(data.level)           -- Current level (1-10)
    print(data.xp)              -- Current XP
    print(data.totalPrints)     -- Lifetime prints collected
    print(data.totalAssembled)  -- Lifetime weapons assembled
end

Since 2.0 the same table also holds v = 2, counts (lifetime counts by action: print, assemble, flawless, fit, fix, sell), classes (mastery points and tallies per weapon class), itemsBuilt (lifetime items built at the bench from printed parts), builtByCategory (the same by item category), stats (earned, bestQuality), goals, milestones (claimed milestones as { [id] = os.time() when claimed }; 0 for ones marked done when the character moved from 1.x), mark (the maker's mark, { name, at }), darkweb (today's dark web purchases) and legacyBonus. Read it; never write it from another resource, or a grant in progress can overwrite your change. A character saved by 1.x is moved to this shape the first time it is read.

Identifying Printed Weapons

Weapons assembled at the bench carry this metadata:

FieldTypeNotes
printedbooleanAlways true on printed weapons
registeredbooleanAlways false — printed weapons are unregistered ghost guns with no serial
printedBystringCharacter id of the builder
printedAtnumberUnix timestamp of assembly
qualitynumberWhole number 5-95
gradestringQuality grade name (Poor/Decent/Standard/Quality/Superior)
durabilitynumberOnly present when Config.Durability.enabled = true. Starts at quality or durabilityMax, whichever is lower
durabilityMaxnumberThe durability cap from the weakest filament among its parts (80, 90 or 100). Missing on weapons built before 2.0; this resource reads that as 100
attachmentstableAttachment ids from Config.Attachments ('suppressor', 'scope' ...)
finishstring or falseA Config.Finishes id when it has a finish. A weapon without one has no finish, or false once an attachment has been fitted or taken off
cleanShotsnumberShots left from a cleaning kit, when cleaned
makerstringThe builder's maker's mark, when they had registered one
description / displaystring / tableTooltip text and the values behind it

When ox_inventory or qb-inventory is running, on any framework (ESX with ox_inventory included), a tint finish is also copied to the inventory's own tint field, which is put on the weapon when it is drawn. When a Mk II livery replaces a tint finish whose tint is still in that field, the field is set back to 0. finish is the source of truth; read it, not tint.

Identifying Printed Parts and USBs

Parts collected from a printer carry this metadata:

FieldTypeNotes
qualitynumberWhole number 0-100: the calibration score, held to the filament tier's cap
filamentTierstring'basic', 'reinforced', or 'carbon' (a key of Config.Filament.tiers)
descriptionstringTooltip text, for example Quality 64 · Basic Filament

Parts printed before 2.0 (and parts given by /weaponprinting giveparts or kit) carry no metadata. This resource treats them as quality 50 (Config.Quality.legacyPart) and the first tier in Config.Filament.order ('basic'). Items printed in one go from Config.ItemPrints (the extended magazine, flashlight, scope, grip, both weapon kits, the lockpick and the finish kits) carry the same three fields plus the item print's own metadata: a finish kit also carries finish, and its description is the kit's name (Gold Finish Kit) instead of the quality line. Items put together at the bench from printed parts (the suppressor and the drum magazine) carry no quality or filament fields, only the item print's own metadata when it sets one (the default ones set none).

Both blueprint USBs carry metadata.blueprint with the blueprint key: printer_usb (permanent, stored on the printer) and printer_usb_once (one-time, loads for one visit to the printer menu).

Reading a Printer's State

Each printer's live state is in a server-written, replicated GlobalState bag named wp:printer:<printerId>. It is updated when something changes (a print starts, finishes, fails, or is collected, the queue or spool changes, the menu opens or closes), not every second. Read it from any server or client script; never write to it.

local bag = GlobalState[('wp:printer:%d'):format(printerId)]
if bag and bag.v == 1 then
    print(bag.status)             -- 'idle' | 'heating' | 'printing' | 'failed' | 'ready'
    print(bag.queue, bag.tray)    -- parts waiting in line, finished parts not yet collected
    if bag.spool then
        print(bag.spool.tier, bag.spool.units, bag.spool.capacity)
    end
end
FieldTypeNotes
vnumberShape version, currently 1
ownerstringCharacter id of the printer's owner
bucketnumberRouting bucket the printer is in
statusstring'idle', 'heating' (someone is calibrating), 'printing', 'failed', or 'ready' (finished parts waiting)
ledstringSame value as status
jobtable or nilThe active print: { id, label, model, layers, startedAt, finishAt, pausedAt, failure }. Times are the server's os.time() seconds. pausedAt is set while the print has failed. failure is { kind = 'warp' | 'spaghetti', at } (at is how far through, 0-1), present only once the print has failed
queuenumberParts waiting behind the active one
traynumberFinished parts waiting to be collected
spooltable or nil{ tier, units, capacity }, or nil when the spool is empty
inUsebooleanSomeone has this printer's menu open
usbstring or nil'once' while a one-time USB is in the front port for the visit that loaded it

Print progress is (now - startedAt) / (finishAt - startedAt) using the server's clock, frozen at pausedAt while failed. The bag is cleared (set to nil) when a printer is picked up or seized.

Reading and Changing Settings

The gameplay settings edited in /weaponprinting settings are saved in the database, and after the first start those saved values replace the config files (see Configuration > The in-game settings menu). Read and change them through these server exports, not the files.

GetSetting

Returns the current value of a top-level Config key.

local seizure = exports['oxide-weaponprinting']:GetSetting('Seizure')
print(seizure.enabled, seizure.dutyOnly)

Parameters:

NameTypeDescription
keystringA top-level Config key ('Seizure', 'Buyers', 'Durability' ...)

Returns: the live value, or nil when there is no such key. In the first seconds after the resource starts, before settingsReady fires, it can still be the config file's value.


SetSetting

Sets a top-level Config key, saves it to the database and applies it live for every player, the same way a save in the settings menu does.

exports['oxide-weaponprinting']:SetSetting('SpawnDistance', 150.0)

Parameters:

NameTypeDescription
keystringA top-level Config key the settings menu edits
valueanyThe whole new value for that key

Returns: boolean - true when saved; false when refused (a key that stays in the config file, such as UseHudAccent or Blueprints, a number that isn't finite, or a call before the settings have loaded) or when the database write fails, in which case the old value stays.

This skips the settings menu's checks on each field, so pass a value of the right shape.

Server Hooks

printStarted

A server-only event, fired whenever a queued part starts printing — whether or not its owner is online. It's triggered with TriggerEvent, so listen with AddEventHandler in another server script (not RegisterNetEvent).

AddEventHandler('oxide-weaponprinting:server:printStarted', function(printerId, data)
    -- data.duration is the print length in seconds
    if data.duration < 30 * 60 then return end
    print(('[my-resource] long print of %s (%s) started on printer %d at %.1f, %.1f, %.1f in bucket %d'):format(
        data.blueprint, data.part, printerId, data.coords.x, data.coords.y, data.coords.z, data.bucket))
end)

Parameters:

NameTypeDescription
printerIdnumberThe printer's id
data.jobIdnumberThe print job's id
data.ownerstringCharacter id of the player who queued it
data.blueprintstringBlueprint key (a Config.Blueprints or Config.ItemPrints key)
data.partstringPart id within the blueprint ('item' for a one-print item)
data.durationnumberPrint length in seconds, after the nozzle and mastery
data.coordsvector3The printer's position
data.bucketnumberThe printer's routing bucket

Server Callbacks

These are registered through the o-link callback bridge (olink.callback.Register) and called by this resource's own client via olink.callback.Trigger. They are not ox_lib callbacks — lib.callback.await will not reach them. Other resources should not call them.

CallbackPurpose
oxide-weaponprinting:server:getSnapshotThe load-time fetch: { printers = {...}, benches = {...}, tables = {...} } in the player's routing bucket. Run on load and again after a routing-bucket change (see the resync client event)
oxide-weaponprinting:server:clockThe server's current os.time(), so clients can work out print progress from the printer state bag
oxide-weaponprinting:server:printer:open / printer:closeStart or end a visit to a printer's menu (locks the printer to that player; ending the visit erases a one-time blueprint)
oxide-weaponprinting:server:printer:viewThe printer menu's data, built on the server
oxide-weaponprinting:server:printer:loadUsbLoad a USB from an inventory slot (permanent: malfunction roll and storage; one-time: this visit only)
oxide-weaponprinting:server:printer:selectSwitch to a stored blueprint
oxide-weaponprinting:server:printer:ejectEject a stored blueprint back onto a USB
oxide-weaponprinting:server:printer:loadFilament / printer:unloadFilamentLoad carried filament onto the spool, or return the spool to the inventory
oxide-weaponprinting:server:printer:queueQueue a part (level, queue depth, spool, and calibration checks; takes filament from the spool)
oxide-weaponprinting:server:printer:cancelCancel a job (refunds filament only if it hadn't started)
oxide-weaponprinting:server:printer:collectCollect the player's finished parts (pays XP)
oxide-weaponprinting:server:printer:upgradeInstall an upgrade item on the printer
oxide-weaponprinting:server:printer:fixStart / printer:fixCompleteFix a failed print (timed on the server)
oxide-weaponprinting:server:printer:discardThrow a failed print away
oxide-weaponprinting:server:printer:calibrateStart / printer:calibrateNext / printer:calibrateCancelRun the print-start calibration (scored on the server)
oxide-weaponprinting:server:checkRemovePre-pickup check (blocks while the printer holds prints; returns the stored blueprint count)
oxide-weaponprinting:server:enterBench / exitBenchLock or unlock a bench while a player uses it (leaving mid-build returns the parts)
oxide-weaponprinting:server:bench:menuThe bench menu: recipes with their parts and quality range, and the printed weapons carried
oxide-weaponprinting:server:bench:startStart an assembly (takes the parts and records them so they can be returned)
oxide-weaponprinting:server:bench:fitFit or take off an attachment, or apply a finish, on a printed weapon
oxide-weaponprinting:server:bench:applyKitFinish using a repair or cleaning kit (timed on the server)
oxide-weaponprinting:server:recycler:getAllThe recyclers in the player's routing bucket
oxide-weaponprinting:server:recycler:enter / recycler:exitStart or end feeding a recycler
oxide-weaponprinting:server:getEquippedPrintedThe drawn printed weapon's durability, jam chance and what to put on it, or nil. durability may be absent when durability is disabled
oxide-weaponprinting:server:getProfile / getGoals / rerollGoalThe Gunsmith profile, its goals, a daily goal swap
oxide-weaponprinting:server:registerMarkRegister or change the maker's mark
oxide-weaponprinting:server:getAppSummary / getAppProfile / getAppPrinters / darkwebBuyThe Gunsmith app: widget summary, profile with library, printers and dark web, printer status, a dark web purchase
oxide-weaponprinting:server:storeInfo / storeBuyThe supplier's rows and a purchase (checked at the supplier, level-gated)
oxide-weaponprinting:server:buyerView / buyerSellA buyer's offers and a sale (checked at the buyer, priced on the server)
oxide-weaponprinting:server:seizeStart / seizeCompletePolice seizure (job, reach, bucket and elapsed time checked)
oxide-weaponprinting:server:settingsFetch / settingsSave / settingsResetThe /weaponprinting settings menu: read the current values, save a batch of changes, reset one setting to its config-file default (admin only)

Server Events

Net events the client sends to the server. All are checked and rate-limited on the server.

EventPayloadPurpose
oxide:weaponprinting:placePrintercoords, rotation, itemSlotPlace a printer at the confirmed position
oxide:weaponprinting:removePrinterprinterId, forceRemovePick up a printer (force = discard stored blueprints)
oxide:weaponprinting:placeBenchcoords, rotationPlace a weapon bench
oxide:weaponprinting:removeBenchbenchIdPick up a bench
oxide:weaponprinting:placeTablecoords, rotationPlace a table
oxide:weaponprinting:removeTabletableIdPick up a table
oxide-weaponprinting:server:recycler:placecoords, rotationPlace a filament recycler
oxide-weaponprinting:server:recycler:removeidPick up a recycler
oxide-weaponprinting:server:recycler:feedid, item, downThe feed button was pressed (down = true) or released; the server times the hold
oxide-weaponprinting:server:bench:inputaction, indexAn assembly minigame input (a part picked, fitted or dropped, the torque button pressed or released)
oxide-weaponprinting:server:bench:bagstateWhat other players should see at the bench (the weapon in the vise, the tool in hand, sound cues)
oxide:weaponprinting:syncShotsshots, slotHintDurability sync, sent every Config.Durability.shotSyncInterval shots. Ignored when durability is disabled
oxide:weaponprinting:calibrate:knobcorner, notchesBed levelling: turn one corner's knob by a number of notches
oxide:weaponprinting:calibrate:heatonNozzle heating: the heater was pressed (true) or released (false)
oxide-weaponprinting:modelUnavailablemodel, kind, reasonA client couldn't load a model; the server warns online admins once per model

Client Events

Net events the server sends to clients.

EventPayloadPurpose
oxide:weaponprinting:addPrinterprinterId, dataA printer was placed — spawn it client-side
oxide:weaponprinting:removePrinterprinterIdA printer was removed — despawn it
oxide:weaponprinting:printerLocked / printerUnlockedprinterIdA printer became busy / free
oxide:weaponprinting:addBenchbenchId, dataA bench was placed
oxide:weaponprinting:removeBenchbenchIdA bench was removed
oxide:weaponprinting:benchLocked / benchUnlockedbenchIdA bench became busy / free
oxide:weaponprinting:addTabletableId, dataA table was placed
oxide:weaponprinting:removeTabletableIdA table was removed
oxide-weaponprinting:client:recycler:add / recycler:removeid, data / idA recycler was placed / removed
oxide:weaponprinting:startPlacementslot, metadataBegin printer placement (after using the item)
oxide:weaponprinting:startBenchPlacement—Begin bench placement
oxide:weaponprinting:startTablePlacement—Begin table placement
oxide-weaponprinting:client:recycler:place—Begin recycler placement
oxide-weaponprinting:client:recycler:resultresultWhat a hold shredded and the filament it made
oxide-weaponprinting:client:bench:assemblypayloadThe assembly minigame as the server scores it, and its result
oxide-weaponprinting:client:bench:useKitkind, weapons, durationA repair or cleaning kit was used: pick the weapon and run the progress bar
oxide:weaponprinting:durabilityUpdatedurability, jamChanceThe drawn printed weapon's durability or jam chance changed
oxide:weaponprinting:weaponBroke—The drawn printed weapon hit 0 durability and was destroyed
oxide:weaponprinting:openManualbookOpen the Ghost Gunner's Handbook. book holds the item images, the reader's level, and every number the pages show, read from the server's config
oxide:weaponprinting:calibrate:statestateThe calibration as the server scores it: step, corner gaps, nozzle temperature, soak time, and the final result
oxide-weaponprinting:client:levelUp / xpGaindataThe level-up banner and the "+XP" pop-up
oxide-weaponprinting:client:gunsmithSummarysummaryFresh data for the Gunsmith widgets and the open app
oxide-weaponprinting:client:dispatchRelaypayloadA print alert relayed through an officer's client when the dispatch resource has no server-side entry point
oxide:weaponprinting:resync—The player's routing bucket changed since their last snapshot — the client fetches getSnapshot again and re-syncs its world props
oxide-weaponprinting:client:OpenSettings—Open the settings menu (/weaponprinting settings, sent after the server's admin check)
oxide-weaponprinting:client:showStats—Open the Gunsmith profile (/weaponprinting stats)

Integration Examples

Example: A dealer that sells a random one-time USB

-- Server: hand the player a random weapon blueprint they're allowed to print
RegisterNetEvent('my-dealer:buyBlueprint', function()
    local src = source
    local data = exports['o-link']:olink().character.GetMetadata(src, 'weaponprinting') or {}
    local level = data.level or 1

    local choices = {}
    for key, bp in pairs(exports['oxide-weaponprinting']:GetBlueprints()) do
        if bp.kind == 'weapon' and bp.level <= level then
            choices[#choices + 1] = key
        end
    end
    if #choices == 0 then return end

    local key = choices[math.random(#choices)]
    exports['oxide-weaponprinting']:GiveBlueprintUsb(src, key, true)  -- one-time USB
end)

Example: Logging every sale to your own system

-- Server
AddEventHandler('oxide-weaponprinting:server:weaponSold', function(src, sale)
    print(('[my-log] %s sold %s (quality %d, maker %s) to %s for $%d'):format(
        src, sale.weapon, sale.quality or 0, sale.maker or 'none', sale.buyer, sale.price))
end)

Example: Checking whether a weapon is printed

-- Server: `item` is an inventory row with its metadata
local function isPrintedWeapon(item)
    return type(item.metadata) == 'table' and item.metadata.printed == true
end

Integration Notes

  • Progression data: read via olink.character.GetMetadata(source, 'weaponprinting') — see above. Never write it
  • Printed weapons: identified by metadata.printed = true. quality and grade are always present; durabilityMax and attachments (a list, possibly empty) on every weapon built since 2.0; durability only when the durability system is enabled; finish and maker when the weapon has them (finish can be false on a weapon without one)
  • Printed parts: carry metadata.quality and metadata.filamentTier; parts from before 2.0 carry neither
  • Blueprint USBs: printer_usb and printer_usb_once carry metadata.blueprint with the blueprint key — see Installation > Distributing Blueprint USBs for giving USBs from shops, scripts, or loot tables
  • Printer state: read GlobalState['wp:printer:<id>']; never write to it
  • Print starts: listen for oxide-weaponprinting:server:printStarted with AddEventHandler on the server
  • All callbacks and net events are checked and rate-limited on the server. Other resources should not trigger them directly

Next Steps