Skip to content

Exports & events ​

np_medic_field is server-authoritative: clients send only what to place and where, and the server checks everything else. Call the exports from trusted server code as exports.np_medic_field:<name>(...).

Server exports ​

server

Export Returns
GetFieldEquipment() Sorted snapshot { id, key, model, owner, bucket, parent, coords, heading, aed, label, door } of every part and AED site
GetTents() { id, model, bucket, x, y, z, heading, label = { title, subtitle, accent, icon } } for tents with a shape
RemoveFieldItem(id, reason?) Removes a part (a tent with everything inside it); true if it existed

Events ​

Event Side Arguments
np_medic_field:placed server, local id, record
np_medic_field:removed server, local id, record, reason (packed, dropped, off_duty, stopped, export)
np_medic_field:built server, local tentId, templateId once a template has finished building
np_medic_field:place / :deploy / :interact / :rpc / :sync client → server Internal; each one is validated and rate limited
np_medic_field:tents server → client Tent list for drawing labels
np_medic_field:notify server → client { text, kind }, shown through np_medic's np_medic:notify (or GTA's feed without np_medic)
lua
AddEventHandler('np_medic_field:removed', function(id, record, reason)
  if reason == 'off_duty' then
    print(('field part %s (%s) packed at duty end'):format(id, record.key))
  end
end)

Addon contract ​

  • Manifest: np_addon 'np_medic'. The server attaches with npAddon.attach('np_medic', fn, { api = 1, label = 'Field camp' }) and fn runs again after every np_medic restart. It also attaches to np_jobs to register its features. See Addons.
  • From np_medic's API 1 it uses exports.np_medic:can(src, feature) for permissions and the client event np_medic:notify for messages.
  • It registers medic.deploy and medic.fieldplan in np_jobs' medic pack (Installation).

NUI contract ​

Two plain HTML pages, no build step: web/index.html (the Feldlager tablet, ui_page) and web/dui.html (the label atlas, never shown directly). Both draw labels with web/label.js.

The tablet calls fetch('https://np_medic_field/<name>'); every callback answers { ok, data?, error? }. Server calls go through rpc { name, args }:

rpc name args data on success
state {} The tablet state (permissions, faction, labels, templates, tents within 30 m, parts)
saveLabel { id?, title, subtitle, accent, icon } { ref, label }
deleteLabel { id } { deleted: ref }
saveTemplate { tent, name, id?, door?: { locked, minGrade } } { id, template }
deleteTemplate { id } { deleted }
setTentLabel { tent, label: ref } { id, label }

The other callbacks are close and deploy { template }. A refusal carries a reason code in error (for example no_plan, too_far, blocked, bad_label, limit_templates); the server also sends the player a message.

Failure behaviour ​

Missing Effect
np_prophandler Nothing can be placed; parts register again on np_prophandler:ready
np_medic Nothing can be placed (no_medic); parts already standing stay
np_doors Doors fall back to np_prophandler doors
np_jobs Permissions come from np_medic's fallback jobs
oxmysql (with store = "oxmysql") Storage falls back to KVP with a warning
DUI or a free slot The baked "FIELD HOSPITAL" sign stays