Skip to content

Screen mirror & privacy glass ​

Players standing next to someone with the phone out see a generic version of that phone's screen on the phone prop: which app is open, roughly what kind of screen it is (a chat thread, a list, a call, the camera), whether it is locked, light or dark, and how bright. They never see content. A privacy glass item, the Hide screen from others setting or an export reduce it to a dark glow.

What bystanders see on the prop: home, chat thread, incoming call, camera, wallet, maps, custom app, lock screen, privacy glass black and cone

The mirror needs the custom hand prop np_phone_handset that ships in stream/ (see Configuration → Phone prop). With the vanilla fallback prop it stays off.

How it works ​

owner NUI ──screen:state──▶ owner client ──np_phone:screen:state──▶ server ──state bag npPhoneScreen──▶ every client
 (real UI)    (coarse state)   (only when changed,       (validates, applies glass,     (replicated,       │
                                 phone open, ≤ 4/s)        hides, rate limit)             server-written)   ▼
                                                                                  viewer: prop lookup, viewing cone,
                                                                                  DUI web/dist/mirror.html → DrawSpritePoly
  1. The phone shell posts the NUI callback screen:state { app, view, locked, theme, brightness, hidden } when it changes (debounced in the NUI).
  2. The owner's client forwards it to the server while the phone is open, only when it differs from the last one and at most every sendInterval ms. Closing the phone sends { off = true }.
  3. The server validates the state, decides the shape (normal / locked / hidden / glass) and writes the player state bag npPhoneScreen. Only the server writes it. A client that writes its own bag gets it overwritten on the next tick, and np_anticheat, when started, gets a low-confidence np_phone.screenBag flag (at most once a minute).
  4. Every client watches the bag. While at least one bag is on, a scan runs every scanInterval ms: nearby owners within distance, their phone prop, and whether the viewer's camera is inside the screen's viewing cone. The nearest maxActive screens get a DUI each (web/dist/mirror.html), drawn as two textured triangles on the screen rectangle of the prop.

The owner's own prop goes through the same path, so in third person your phone shows your own (generic) screen.

Privacy model ​

  • The server never publishes content. The bag holds an app id, a view kind from a fixed list, locked, theme, brightness, and with privacy glass a glass mode. No names, text, numbers, amounts, photos or locations. A modified viewer client has nothing to reveal: the state bag is all it receives.
  • The owner's client can't inject content. Every field is re-validated on the server: the app id must be a built-in app, 'home' or an app registered through registerStoreApp (anything else becomes 'custom'), the view must be in Config.ScreenMirror.views[app] (anything else is dropped), brightness is clamped to 0–1 in 0.05 steps, the theme is dark or light. Unknown fields are discarded.
  • Privacy glass comes from the inventory, read on the server. A client can't claim it, and can't remove it either.
  • Hiding only ever reduces what is shown. The Hide screen from others setting (key hideScreen), the client export setLocalScreenHidden, the server export setScreenHidden and Config.ScreenMirror.apps all lead to the same minimal shape.
  • The mirror page renders placeholder templates (grey bars, bubbles, a fake map grid). Custom apps show their App Store icon, tint and name, which are public catalog data (GlobalState npPhoneMirrorApps).

Why not mirror the real UI

Showing the owner's actual phone UI to others was rejected: messages, contacts, balances, photos and live locations would have to leave the owner's client, where any modified client could read them at any distance, and every app would need a second, synchronised data channel. At prop size real text is unreadable anyway; a skeleton reads the same.

Bag shapes ​

Player(src).state.npPhoneScreen (server-written, replicated):

Case Value
Phone closed, mirror off, no phone profile, blocked, no phone item nil
Normal { on = true, app, view?, locked = false, theme, brightness } (app = 'home': home screen)
Locked { on = true, locked = true, theme, brightness }
Hidden (setting, export, opted-out app) or glass 'black' { on = true, brightness }
Glass 'cone' { on = true, app?, locked?, theme, brightness, glass = 'cone' } (never a view; locked hides the app)

Precedence: hidden > privacy glass > locked > normal.

On the viewer side, normal screens are drawn inside ±normalCone° of the screen normal. Glass 'cone' screens show their app skeleton inside ±glassCone° and a dark glow between glassCone and normalCone. Outside normalCone nothing is drawn, and screens beyond distance are never drawn.

Configuration ​

shared/config/screen.lua (Config.ScreenMirror, escrow-ignored). The main toggles are also editable in np_admin under Settings → Phone → Screen mirror.

Key Default Description
enabled true Server-wide switch. Also set np_phone:screen_mirror false in server.cfg (read once on start)
distance 2.5 Metres between viewer and owner
normalCone / glassCone 65 / 12 Viewing cones in degrees from the screen normal
maxActive 2 Screens drawn at once per viewer (nearest first), one DUI each
scanInterval 350 ms between scans (clamped to 250–500)
resolution { w = 180, h = 385 } DUI size in pixels
idleRelease 15000 ms before an unused DUI is destroyed
flipWinding false Swap the triangle winding if the screen is invisible from the front
sendInterval 250 Owner: minimum ms between two updates to the server
rateLimit { perSecond = 4, burst = 8 } Server: publishes per player. Extra updates are deferred (newest wins), not dropped
glass.item 'privacy_glass' Item that counts as privacy glass (false = none)
glass.metadata 'privacyGlass' ox_inventory: metadata flag on a phone item (Config.ItemNames), false = no metadata check
glass.mode 'black' 'black': viewers only see that the screen is on. 'cone': viewers straight behind the owner see which app is open (no view details), everyone else a dark glow
glass.cacheMs 5000 Inventory check cache per player
callerName false Reserved, not implemented (the mirror never sends names)
apps {} App ids that are never shown, e.g. { 'darkchat', 'wallet' }: viewers only see a dark glow
views per app View kinds the NUI may report: messages list thread, phone incoming outgoing active dialer list, camera photo video selfie. Keep in sync with SCREEN_VIEWS in web/src/lib/screen.ts

The screen rectangle on the prop lives in Config.Prop.screen. Without it the mirror is off for that model.

Player setting ​

Settings → Hide screen from others (settings key hideScreen, default false) gives the player's own screen the hidden shape: others only see that the screen is on.

Privacy glass ​

Any of these makes a player's screen private while it is in their inventory:

  • the item glass.item (default privacy_glass), with any framework inventory (the framework bridge's hasItem);
  • with ox_inventory, a phone item (Config.ItemNames) whose metadata has privacyGlass = true, for example a phone a shop script fitted with a glass: exports.ox_inventory:SetMetadata(src, slot, { privacyGlass = true });
  • a bridge override: exports.np_phone:overrideBridge('framework', 'hasPrivacyGlass', function(src) return ... end).

The result is cached for glass.cacheMs and re-checked when the phone opens, every cacheMs while it is open, and at once on ox_inventory moves of the item (swapItems / createItem hooks) and on ESX esx:onAddInventoryItem / esx:onRemoveInventoryItem. The item does nothing when used.

Item definitions ​

lua
-- ox_inventory/data/items.lua (also qbx with ox_inventory)
['privacy_glass'] = {
  label = 'Privacy screen protector',
  weight = 10,
  stack = false,
  description = 'Others only see a dark screen.',
},
lua
-- qb-core/shared/items.lua
privacy_glass = { name = 'privacy_glass', label = 'Privacy screen protector', weight = 10, type = 'item',
  image = 'privacy_glass.png', unique = true, useable = false, shouldClose = false,
  description = 'Others only see a dark screen.' },
sql
INSERT INTO items (name, label, weight, rare, can_remove) VALUES ('privacy_glass', 'Privacy screen protector', 1, 0, 1);

Exports and events ​

server

Export Returns Description
setScreenHidden(src, hidden) boolean Force the hidden shape for src, per calling resource (undercover jobs, events). Released when your resource stops
getScreenState(src) table | nil Copy of the current npPhoneScreen bag value, nil when the phone is closed or the mirror is off
hasPrivacyGlass(src) boolean Privacy glass check (cached glass.cacheMs)

client

Export Returns Description
isScreenMirrorActive() boolean This client draws at least one screen
setLocalScreenHidden(hidden) Hide this player's screen from others, per calling resource (released on stop). Applied by the server like the Hide screen setting

Server event np_phone:screenStateChanged (src, state | nil): the bag of src changed (state is a copy).

lua
-- server: an undercover job hides the officer's screen while on duty
exports.np_phone:setScreenHidden(src, true)

AddEventHandler('np_phone:screenStateChanged', function(src, state)
  if state and state.app == 'darkchat' then --[[ ... ]] end
end)

Performance ​

  • No phone open anywhere: nothing runs (no threads, no DUIs).
  • A phone open somewhere: one scan every 250–500 ms over the players whose bag is on (distance check first; the prop lookup is a GetClosestObjectOfType at the hand, cached per player, failed lookups retried once a second).
  • A screen visible: one draw thread, two DrawSpritePoly and four GetOffsetFromEntityInWorldCoords per screen per frame, one DUI per visible screen (default max 2). The thread ends when no screen is visible; DUIs are destroyed after idleRelease.
  • Owner: one small event per state change (≤ 4/s), nothing while the phone is closed. Server: a 5 s re-check loop only while at least one phone is open, bag writes only on real changes (brightness in 0.05 steps).

Limitations ​

  • The prop is found by model next to the owner's hand. Two players with phones in the same spot are told apart by the attachment check; a phone that isn't attached to its owner (ragdoll, cutscene) isn't drawn.
  • The cone uses the rendered camera position, the distance the ped position.
  • The camera app hands over to the GTA cell phone camera and puts the phone away, so the bag is off while it runs; the camera views only show before that hand-over.
  • Not yet verified in game: the Config.Prop.screen alignment, the triangle winding (flipWinding) and the normal direction (sign of right). Check these after changing the model.