NUI contract ​
np_screens has three kinds of web pages: the shell (the ui_page, with the player UIs inside it), the viewer
(the page every in-world screen renders) and the phone app that np_phone loads. You only need this page to change
the UI or to debug it.
The shell ​
ui_page is web/editor/dist/index.html, built from web/editor/ (React, TypeScript, Vite, Fabric.js). It is the
whiteboard editor itself, and it hosts the other player UIs as iframes:
| App | Source | iframe |
|---|---|---|
remote |
web/remote/ |
nui-remote |
audio |
web/audio/ (the NUI audio fallback) |
nui-audio |
admin |
web/admin/ (Surface manager and placement HUD) |
nui-admin |
presenter |
web/presenter/ |
nui-presenter |
hud |
web/hud/ (Now showing pill, prompts) |
nui-hud |
The prebuild step copies these folders and web/shared/ (fonts, icons, Nimbus UI) into the build.
Routing. FiveM delivers every SendNUIMessage to the root frame only, so every payload carries
app = 'remote' | 'audio' | 'admin' | 'presenter' | 'hud' | 'editor' and the shell posts it into the matching iframe.
An untagged audio:* action still goes to the audio page. Payloads for editor stay in the shell.
Focus. A child posts { app, action: 'visibility', open } up to the shell when its interactive UI opens or
closes, and its frame becomes clickable while open. The shell keeps a stack of open apps, so Esc goes to the topmost.
The hud app is display-only and never takes pointer events.
Theme. The client forwards np_admin's server theme as { action = 'theme', type = 'theme', data = theme }. The
shell applies it and every app follows it (see Configuration → Theme).
Callbacks. Each app posts to https://np_screens/<name>. The client half of each feature validates the input
and forwards it to the server, which checks everything again:
| Area | Callbacks |
|---|---|
| Remote | play, seek, volume, setMetadata, queueRemove, remote:queueMove, remote:mute, remote:pref, slideNext, slidePrev, slideSet, editBoard, clearBoard |
| Library | lib:*, lib:preview, lib:report |
| Cinema | cinema:*, cinema:refresh, cinema:setOption |
| Presenter | presenter:open, presenter:minimise, presenter:end, presenter:close |
| Surface manager | admin:rpc (one request / reply pair for every manager operation), admin:placement, admin:placementForm, admin:local, admin:close |
| Editor | save, close, mirror, setMedia, clearMedia, editor:op, editor:cursor, editor:snapshot, editor:draft, editor:draftDiscard, editor:lock, editor:rpc (history, version preview, upload links, restore) |
| Cast | cast:transport, cast:openRemote (from the phone app) |
Remote payloads must carry a caps block: the remote fails closed (view only) without it. content.slideIndex is
1-based in the remote and 0-based on the server, and the client converts both ways.
The viewer ​
web/viewer/index.html is plain HTML and JS with no build step. The client creates Config.DuiPool browsers at
https://cfx-nui-np_screens/web/viewer/index.html, each at Config.DefaultResolution, and hands them to surfaces as
they come into range. Messages are JSON sent with SendDuiMessage, in three families:
| Message | Does |
|---|---|
action: image, poster, iframe, video, pdf, deck, slide, error |
Show a content: a snapshot or image, a poster frame, an embed, a video file, a PDF page, an image deck and its slide, or an error card |
type = 'transport', op: load, play, pause, seek, stop, volume, loop, timesync |
Transport for synced video. timesync carries the server clock offset, so the page computes the position itself |
type = 'overlay' (op: laser, blackout, eas, state), idle, feed, captions, prefs, reset |
Overlays on top of the content: the laser dot, blackout, the emergency card, the syncing and poster states, the screensaver, the Chirp wall, captions, player preferences (reduced motion) and clearing them all |
web/viewer/index.html?dev=1 adds buttons for every overlay in a browser, and ?state=<name> renders one fixed frame.
The viewer is not themed and has no NUI focus.
The phone app ​
web/phone/ is the Cast app, plain HTML and JS. np_phone loads it from cfx-nui-np_screens/web/phone/ after
np_screens registers it with registerStoreApp. It talks to the server through np_phone's app RPCs
(init, nearby, surface, castLink, photos, castPhotos, castChirp, stop, control), answered by
server/ext/70_cast.lua with the player's real server id. web/phone/dev.html runs it in a browser with a mock phone.