Item hook events#
nx_computer exposes two client events as ox_inventory item hooks. They are
triggered by the item definition when a player uses the item, not by external
code. Set them as the client.event on the matching item in ox_inventory
data/items.lua.
The laptop item opens the in-world laptop:
['laptop'] = { label = 'Laptop', weight = 1000, stack = false, close = true, client = { event = 'nx_computer:client:useLaptop' },},The projector item opens the projector:
['projector'] = { label = 'Projector', weight = 2000, stack = true, close = true, client = { event = 'nx_computer:client:useProjector' },},Neither event takes a payload.
nx_computer:client:useLaptop depends on where the player is:
- On foot, it starts a placement. The player aims and confirms, and the item is
consumed on confirmation. The laptop sets down on any valid surface,
including a vehicle panel such as a bonnet, roof, or boot unless
Config.VehiclePlacement.Enabledisfalse. - Seated in a vehicle, it opens the laptop on the player's lap with no
placing step. Using the item again closes it. This lap mode is off when
Config.Vehicle.Enabledisfalse, and the item then falls back to placement.
nx_computer:client:useProjector starts a ceiling placement the same way. It
does nothing when Config.Projector.Enabled is false.
For back-compat, the legacy alias nx_laptop:client:useLaptop is also accepted
in place of nx_computer:client:useLaptop. It is registered only when the
legacy resource is not running at the time nx_computer starts, so the two
cannot both open a laptop.
The camera and polaroid items use client.export instead of client.event.
Their entry points are documented on the exports page: useCamera
for the camera, usePolaroid and placePolaroid for the polaroid. The darknet
access item needs no hook at all, since it is a presence check.
Server-side event mirrors#
Two server exports have a matching server event, for resources that prefer events over exports. Both do exactly what the export does. Both refuse any caller other than the server itself and print the rejection to the server console, so a client cannot forge system mail or push a notification to an arbitrary account.
nx_computer:email:sendSystem takes the same payload as sendSystemEmail:
TriggerEvent('nx_computer:email:sendSystem', { to = '@jdoe', subject = 'Your order shipped', body = 'Your package is on the way.', sourceApp = 'store',})nx_computer:notifications:push takes the same payload as PushNotification:
TriggerEvent('nx_computer:notifications:push', { handle = '@jdoe', appId = 'store', title = 'Order ready', message = 'Your pizza is waiting at the counter.', severity = 'success',})A notification pushed with an appId of email, mail, or messages is also
forwarded to the player's phone when the phone bridge is active
(Config.PhoneBridge).
nx_computer:transactions:record is a server-local event that takes the same
payload as RecordTransaction. It is not a network event, so only server code
can fire it:
TriggerEvent('nx_computer:transactions:record', { computerId = computerId, accountId = accountId, entryType = 'job_payout', assetSymbol = 'USD', assetAmount = 1, fiatTotal = 850,})The exports return a result and these events do not. Prefer the export when you need to know whether the write succeeded.
Newsroom stories#
Whenever a Newsroom story changes, nx_computer fires a server-local event. It is not a network event, so a client can never raise it. Listen to it from your own server script to post new stories to Discord or ring phones:
AddEventHandler('nx_computer:server:newsEvent', function(kind, story) if kind == 'published' and story.breaking then print(('Breaking: %s by %s'):format(story.title, story.author.name)) endend)kind: one ofsaved,published,unpublished,deletedorimported.story: a table ofid,title,standfirst,category,status(publishedordraft),breaking,author(nameandjob), andphotoIds(the phone photo ids the story shows).
Permissions ready#
nx_computer:permissionsReady is a server-local event that fires once nx_computer has
started and accepts the permission exports (SetSiteBuilderRanks, SetSiteBuilderAccess,
SetNewsroomJob). Those settings live in memory, so register them again here whenever
nx_computer restarts. See Exports.
AddEventHandler('nx_computer:permissionsReady', function() exports['nx_computer']:SetNewsroomJob('lsnews', 0)end)MDT events#
The MDT announces what happens on it as server-local events named
nx_computer:mdt:<name>. They are never sent to a client, so a client can
never raise or read them. Listen from any server script to fine a bank
account, jail a player, post to Discord or give a reward, without polling:
AddEventHandler('nx_computer:mdt:ticketIssued', function(data) print(data.number, data.amount, data.identifier, data.source)end)| Event | Fields |
|---|---|
caseOpened | caseId, number, agency, title, personId |
reportFiled | reportId, number, agency, kind, state (filed or approved), personId |
reportApproved | reportId, number, agency, kind, personId |
ticketIssued | ticketId, number, agency, amount, codes, target (person or plate), plate, citizenId, identifier, source, personId |
ticketPaid | ticketId, number, agency, via |
ticketVoided | ticketId, number, agency, personId |
sentenceChanged | sentenceId, from, to (serving, served, escaped, voided, appealed or signed), minutes (remaining, on serving), citizenId, identifier, source, personId |
boloRaised | boloId, number, agency, kind (person or plate), code, plate, citizenId, identifier, source, personId |
callCreated | callId, callNo, ownerAgencyId, services, kind, origin, priority, state, pos |
callClosed | The same as callCreated, plus outcome |
dutyStarted | personId, agency, shiftId |
dutyEnded | personId, reason |
agencyis the agencykeyfromConfig.MDT.Agencies.personIdis the MDT's own record id for the officer.- When an event names a citizen, it also carries
identifier(the ESX identifier or the QBCore / Qbox citizenid) and, while that player is online,source. Neither is ever shown on the MDT. - Fields that only apply sometimes, such as
plateon a person ticket, are nil when they do not apply.
The events are raised from server/mdt/hooks.lua, which stays readable and
editable in the escrowed build. Code you add to its Hooks.Emit function runs
for every event.
MDT jail hand-off#
When an MDT sentence starts serving, nx_computer can hand it to your jail
script. The event names are yours: set them in Config.MDT.JailAdapter. The
default mode is 'none', which only records the sentence.
| Mode | What nx_computer does |
|---|---|
custom | Runs your own code in the custom function of server/mdt/jail.lua, an open file. |
server_event | TriggerEvent(ServerEvent, src, minutes, data) on the server. |
client_event | TriggerClientEvent(ClientEvent, src, src, minutes, data), sent to the sentenced player. |
export | Calls exports[resource]:fn(src, minutes, data) when that resource is started. |
The arguments are:
src: the server id of the sentenced player, resolved on the server.minutes: the remaining minutes (term minus credit minus time served).data: a table withminutes,sentenceId,citizenIdentifier(the framework identifier), andreasonwhen one was given.
The hand-off fires only while the citizen is online. An offline citizen is recorded as deferred, and the hand-off retries the next time the sentence enters serving. Most jail scripts expect their own argument shape and units, so point the adapter at a small shim event in your own resource and convert there:
-- Config.MDT.JailAdapter = { Mode = 'server_event', ServerEvent = 'myshim:mdtJail' }AddEventHandler('myshim:mdtJail', function(src, minutes, data) -- Call your jail script here. Check its docs for the expected units.end)Or set Mode = 'custom' and write the call straight into server/mdt/jail.lua.
The file's header has examples for common jail scripts. A release (served,
voided, appealed) arrives as the sentenceChanged event above.
The MDT on another phone or HUD#
With nx_phone, officers get an MDT app on the phone, and the in-car Dash is
drawn by nx_hud when it runs. Another phone or HUD can do the same through a
small client-side surface. The shapes are described in docs/POCKET.md and
docs/DASH.md inside the resource.
- A phone app calls the
nx_computer:pocket:*ox_lib callbacks, which check the same permissions as the field keys, and listens to the client eventsnx_computer:dispatch:fieldandnx_computer:dispatch:board. A phone that shows its own call alerts setsLocalPlayer.state:set('nxPocketAlerts', true, false)while it does, andfalsewhen it stops. nx_computer then leaves the call sound and pop-up to the phone. - A HUD draws the Dash by listening to the client-local event
nx_computer:dash:model, sending clicks back withTriggerEvent('nx_computer:dash:act', act), and settingLocalPlayer.state.nxDashHostwhile it draws. With no host set, nx_computer draws its own copy.
NPC mailboxes and darknet vendors#
Server-local events, so a client can never raise them. Each one carries the same table the matching handler gets.
-- A player wrote to an NPC mailbox (RegisterMailbox).AddEventHandler('nx_computer:server:mailToMailbox', function(mail) -- mail.mailbox, mail.from, mail.fromName, mail.accountId, mail.subject, mail.body, mail.emailId, mail.sourceend)-- A player bought from an NPC darknet vendor (CreateDarknetListing) ...AddEventHandler('nx_computer:server:darknetNpcPurchase', function(order) -- order.listingId, order.vendor, order.item, order.amount, order.price, -- order.accountId, order.identifier, order.sourceend)-- ... and has the goods (the courier handed them over, or an instant listing).AddEventHandler('nx_computer:server:darknetNpcCollected', function(order) end)No other public events#
Every other nx_computer:* network event is internal. Auth, sessions and
multiple accounts, laptop, monitor and projector placement (including
vehicle placement and lap mode), app and directory-site sync, notification
and message delivery, email and email forwarding, media upload, the camera,
polaroid placement, Meetings (signalling, voice channel, and participant
control), the MDT's own screens and dispatch traffic, bodycam and live view, the file system, the store,
darknet orders and hand-overs, casino, vehicle offers, and market order
traffic are all events nx_computer fires for itself. What nearby players see
of a laptop screen is mirrored through nx-3d, not through nx_computer events.
None of these are a supported integration point. Triggering or listening to
them from another resource is unsupported and may break between versions.
Apart from the events above, the phone integrations do not use events of
their own. The phone bridge calls lb-phone's SendNotification export
directly, and other resources can reach it through the PhoneNotify server
export. Phone photo
sync listens to lb-phone's own server event lb-phone:deletedFromGallery to
remove mirrored photos.
The supported integration surface is the exports and the SDK.
