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
GiveBlueprintUsbandGetBlueprints, and the matchinggiveBlueprintUsbserver event - the server exports
GetSettingandSetSetting, 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-timeParameters:
| Name | Type | Description |
|---|---|---|
| src | number | The player's server ID |
| blueprint | string | A Config.Blueprints or Config.ItemPrints key ('pistol', 'suppressor', 'finish_gold' ...) |
| once | boolean (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)
endReturns: 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)| Name | Type | Description |
|---|---|---|
| src | number | The player's server ID |
| blueprint | string | A Config.Blueprints or Config.ItemPrints key |
| once | boolean (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.
| Event | Args | When |
|---|---|---|
oxide-weaponprinting:server:blueprintGiven | src, blueprint, once, from | A 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:levelUp | src, level, previous | A player reached a new level by earning XP, or an admin raised it (/weaponprinting setlevel or setxp) |
oxide-weaponprinting:server:progressionGranted | src, key, xp | A 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:weaponSold | src, sale | A 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:seized | officerSrc, kind, id, ownerCharId, evidence | Police 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:printStarted | printerId, data | A 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):
| Event | Args | Description |
|---|---|---|
oxide-weaponprinting:client:openProfile | from? | Opens the Gunsmith profile. from is any string; it's handed back when the profile closes |
oxide-weaponprinting:client:profileClosed | from | The 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
endSince 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:
| Field | Type | Notes |
|---|---|---|
printed | boolean | Always true on printed weapons |
registered | boolean | Always false — printed weapons are unregistered ghost guns with no serial |
printedBy | string | Character id of the builder |
printedAt | number | Unix timestamp of assembly |
quality | number | Whole number 5-95 |
grade | string | Quality grade name (Poor/Decent/Standard/Quality/Superior) |
durability | number | Only present when Config.Durability.enabled = true. Starts at quality or durabilityMax, whichever is lower |
durabilityMax | number | The 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 |
attachments | table | Attachment ids from Config.Attachments ('suppressor', 'scope' ...) |
finish | string or false | A 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 |
cleanShots | number | Shots left from a cleaning kit, when cleaned |
maker | string | The builder's maker's mark, when they had registered one |
description / display | string / table | Tooltip 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:
| Field | Type | Notes |
|---|---|---|
quality | number | Whole number 0-100: the calibration score, held to the filament tier's cap |
filamentTier | string | 'basic', 'reinforced', or 'carbon' (a key of Config.Filament.tiers) |
description | string | Tooltip 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| Field | Type | Notes |
|---|---|---|
v | number | Shape version, currently 1 |
owner | string | Character id of the printer's owner |
bucket | number | Routing bucket the printer is in |
status | string | 'idle', 'heating' (someone is calibrating), 'printing', 'failed', or 'ready' (finished parts waiting) |
led | string | Same value as status |
job | table or nil | The 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 |
queue | number | Parts waiting behind the active one |
tray | number | Finished parts waiting to be collected |
spool | table or nil | { tier, units, capacity }, or nil when the spool is empty |
inUse | boolean | Someone has this printer's menu open |
usb | string 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:
| Name | Type | Description |
|---|---|---|
| key | string | A 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:
| Name | Type | Description |
|---|---|---|
| key | string | A top-level Config key the settings menu edits |
| value | any | The 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:
| Name | Type | Description |
|---|---|---|
| printerId | number | The printer's id |
| data.jobId | number | The print job's id |
| data.owner | string | Character id of the player who queued it |
| data.blueprint | string | Blueprint key (a Config.Blueprints or Config.ItemPrints key) |
| data.part | string | Part id within the blueprint ('item' for a one-print item) |
| data.duration | number | Print length in seconds, after the nozzle and mastery |
| data.coords | vector3 | The printer's position |
| data.bucket | number | The 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.
| Callback | Purpose |
|---|---|
oxide-weaponprinting:server:getSnapshot | The 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:clock | The server's current os.time(), so clients can work out print progress from the printer state bag |
oxide-weaponprinting:server:printer:open / printer:close | Start 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:view | The printer menu's data, built on the server |
oxide-weaponprinting:server:printer:loadUsb | Load a USB from an inventory slot (permanent: malfunction roll and storage; one-time: this visit only) |
oxide-weaponprinting:server:printer:select | Switch to a stored blueprint |
oxide-weaponprinting:server:printer:eject | Eject a stored blueprint back onto a USB |
oxide-weaponprinting:server:printer:loadFilament / printer:unloadFilament | Load carried filament onto the spool, or return the spool to the inventory |
oxide-weaponprinting:server:printer:queue | Queue a part (level, queue depth, spool, and calibration checks; takes filament from the spool) |
oxide-weaponprinting:server:printer:cancel | Cancel a job (refunds filament only if it hadn't started) |
oxide-weaponprinting:server:printer:collect | Collect the player's finished parts (pays XP) |
oxide-weaponprinting:server:printer:upgrade | Install an upgrade item on the printer |
oxide-weaponprinting:server:printer:fixStart / printer:fixComplete | Fix a failed print (timed on the server) |
oxide-weaponprinting:server:printer:discard | Throw a failed print away |
oxide-weaponprinting:server:printer:calibrateStart / printer:calibrateNext / printer:calibrateCancel | Run the print-start calibration (scored on the server) |
oxide-weaponprinting:server:checkRemove | Pre-pickup check (blocks while the printer holds prints; returns the stored blueprint count) |
oxide-weaponprinting:server:enterBench / exitBench | Lock or unlock a bench while a player uses it (leaving mid-build returns the parts) |
oxide-weaponprinting:server:bench:menu | The bench menu: recipes with their parts and quality range, and the printed weapons carried |
oxide-weaponprinting:server:bench:start | Start an assembly (takes the parts and records them so they can be returned) |
oxide-weaponprinting:server:bench:fit | Fit or take off an attachment, or apply a finish, on a printed weapon |
oxide-weaponprinting:server:bench:applyKit | Finish using a repair or cleaning kit (timed on the server) |
oxide-weaponprinting:server:recycler:getAll | The recyclers in the player's routing bucket |
oxide-weaponprinting:server:recycler:enter / recycler:exit | Start or end feeding a recycler |
oxide-weaponprinting:server:getEquippedPrinted | The 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 / rerollGoal | The Gunsmith profile, its goals, a daily goal swap |
oxide-weaponprinting:server:registerMark | Register or change the maker's mark |
oxide-weaponprinting:server:getAppSummary / getAppProfile / getAppPrinters / darkwebBuy | The Gunsmith app: widget summary, profile with library, printers and dark web, printer status, a dark web purchase |
oxide-weaponprinting:server:storeInfo / storeBuy | The supplier's rows and a purchase (checked at the supplier, level-gated) |
oxide-weaponprinting:server:buyerView / buyerSell | A buyer's offers and a sale (checked at the buyer, priced on the server) |
oxide-weaponprinting:server:seizeStart / seizeComplete | Police seizure (job, reach, bucket and elapsed time checked) |
oxide-weaponprinting:server:settingsFetch / settingsSave / settingsReset | The /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.
| Event | Payload | Purpose |
|---|---|---|
oxide:weaponprinting:placePrinter | coords, rotation, itemSlot | Place a printer at the confirmed position |
oxide:weaponprinting:removePrinter | printerId, forceRemove | Pick up a printer (force = discard stored blueprints) |
oxide:weaponprinting:placeBench | coords, rotation | Place a weapon bench |
oxide:weaponprinting:removeBench | benchId | Pick up a bench |
oxide:weaponprinting:placeTable | coords, rotation | Place a table |
oxide:weaponprinting:removeTable | tableId | Pick up a table |
oxide-weaponprinting:server:recycler:place | coords, rotation | Place a filament recycler |
oxide-weaponprinting:server:recycler:remove | id | Pick up a recycler |
oxide-weaponprinting:server:recycler:feed | id, item, down | The feed button was pressed (down = true) or released; the server times the hold |
oxide-weaponprinting:server:bench:input | action, index | An assembly minigame input (a part picked, fitted or dropped, the torque button pressed or released) |
oxide-weaponprinting:server:bench:bag | state | What other players should see at the bench (the weapon in the vise, the tool in hand, sound cues) |
oxide:weaponprinting:syncShots | shots, slotHint | Durability sync, sent every Config.Durability.shotSyncInterval shots. Ignored when durability is disabled |
oxide:weaponprinting:calibrate:knob | corner, notches | Bed levelling: turn one corner's knob by a number of notches |
oxide:weaponprinting:calibrate:heat | on | Nozzle heating: the heater was pressed (true) or released (false) |
oxide-weaponprinting:modelUnavailable | model, kind, reason | A client couldn't load a model; the server warns online admins once per model |
Client Events
Net events the server sends to clients.
| Event | Payload | Purpose |
|---|---|---|
oxide:weaponprinting:addPrinter | printerId, data | A printer was placed — spawn it client-side |
oxide:weaponprinting:removePrinter | printerId | A printer was removed — despawn it |
oxide:weaponprinting:printerLocked / printerUnlocked | printerId | A printer became busy / free |
oxide:weaponprinting:addBench | benchId, data | A bench was placed |
oxide:weaponprinting:removeBench | benchId | A bench was removed |
oxide:weaponprinting:benchLocked / benchUnlocked | benchId | A bench became busy / free |
oxide:weaponprinting:addTable | tableId, data | A table was placed |
oxide:weaponprinting:removeTable | tableId | A table was removed |
oxide-weaponprinting:client:recycler:add / recycler:remove | id, data / id | A recycler was placed / removed |
oxide:weaponprinting:startPlacement | slot, metadata | Begin 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:result | result | What a hold shredded and the filament it made |
oxide-weaponprinting:client:bench:assembly | payload | The assembly minigame as the server scores it, and its result |
oxide-weaponprinting:client:bench:useKit | kind, weapons, duration | A repair or cleaning kit was used: pick the weapon and run the progress bar |
oxide:weaponprinting:durabilityUpdate | durability, jamChance | The drawn printed weapon's durability or jam chance changed |
oxide:weaponprinting:weaponBroke | — | The drawn printed weapon hit 0 durability and was destroyed |
oxide:weaponprinting:openManual | book | Open 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:state | state | The calibration as the server scores it: step, corner gaps, nozzle temperature, soak time, and the final result |
oxide-weaponprinting:client:levelUp / xpGain | data | The level-up banner and the "+XP" pop-up |
oxide-weaponprinting:client:gunsmithSummary | summary | Fresh data for the Gunsmith widgets and the open app |
oxide-weaponprinting:client:dispatchRelay | payload | A 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
endIntegration Notes
- Progression data: read via
olink.character.GetMetadata(source, 'weaponprinting')— see above. Never write it - Printed weapons: identified by
metadata.printed = true.qualityandgradeare always present;durabilityMaxandattachments(a list, possibly empty) on every weapon built since 2.0;durabilityonly when the durability system is enabled;finishandmakerwhen the weapon has them (finishcan befalseon a weapon without one) - Printed parts: carry
metadata.qualityandmetadata.filamentTier; parts from before 2.0 carry neither - Blueprint USBs:
printer_usbandprinter_usb_oncecarrymetadata.blueprintwith 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:printStartedwithAddEventHandleron the server - All callbacks and net events are checked and rate-limited on the server. Other resources should not trigger them directly
Next Steps
- Features - Understand the systems these APIs power
- Configuration - Customize the settings that affect API behavior
- Troubleshooting - Debug integration issues