Installation ​
Requirements ​
- A recent FiveM server artifact (Lua 5.4). Lock codes are hashed with the server natives
GetPasswordHash/VerifyPasswordHash - oxmysql
- np_prophandler 1.1.0+: lock doors and keypad props. It must start before np_passwords
- Node 18+ to build the NUI once
Optional, auto-detected at start:
| Kind | Resources | Used for |
|---|---|---|
| Framework | es_extended, qbx_core, qb-core | Character id and name, jobs, grades and duty (job-owned locks, job vaults, warrant). Without one, np_passwords runs standalone (see Bridges) |
| Inventory | np_inventory, ox_inventory, qb-inventory | The items paper_note, code_breaker, search_warrant. np_inventory also brings runtime item registration and stash locks |
| HUD | np_hud | Save / update toasts with Y / N, proximity prompts (E / G / H), hiding the HUD centre while a panel is open |
| Phone | np_phone | The Passwords app, owner alerts with deep links, 2FA SMS, badge |
| Gangs | np_gangs | Gang vaults, flagging after a member leaves, the opt-in gang stash lock |
| Menu | np_menu | "Watch them type" and "Read keychain (warrant)" on players |
| Documents | np_identification | Optional badge check for the warrant read |
| Characters | np_character | Character id and name in standalone mode |
| Staff | np_admin | Permissions, live settings and staff actions. Without it, a fallback decides who is staff |
Steps ​
- Put the resource in
resources/asnp_passwords. The NUI callbacks usehttps://np_passwords/…(the web components of other resources too), and other resources callexports.np_passwords, so keep the name. - Build the NUI:shThis creates
cd web && npm ci && npm run buildweb/dist/index.html(prompts, generator, crack, toasts, warrant sheet),web/dist/phone.html(the np_phone app) andweb/dist/components/np-pw.js(the web components).web/distis not committed, so a fresh clone starts with a blank UI until you build it. - Set the encryption secret in
server.cfg. Keychain entries, vault items and 2FA secrets are encrypted with keys derived from it. Use a long random value (at least 16 characters, 32+ recommended), andset, neversetr:cfgGenerate one withset np_passwords:secret "paste-a-long-random-string-here-and-keep-it"openssl rand -base64 48. Keep it: with a different secret, saved codes can't be decrypted any more. - Database: with
Config.AutoCreateTables = true(the default) the 9 tables are created at start. Otherwise importsql/np_passwords.sqlyourself. - Items: np_inventory gets them at runtime, so skip this step there. With ox_inventory, add them to
ox_inventory/data/items.luawith np_passwords' item callback:luaWith qb-inventory, add the three items to the shared items. See Bridges → Inventory.['paper_note'] = { label = 'Paper note', weight = 10, stack = false, close = true, server = { export = 'np_passwords.itemUse' } }, ['code_breaker'] = { label = 'Code breaker', weight = 400, stack = true, close = true, server = { export = 'np_passwords.itemUse' } }, ['search_warrant'] = { label = 'Search warrant', weight = 20, stack = true, close = true, server = { export = 'np_passwords.itemUse' } }, - Add to
server.cfg. Start np_passwords after np_prophandler, the framework, the inventory and the optional resources it talks to, and before the resources that register locks:cfgThere are noset np_passwords:secret "…" ensure oxmysql ensure es_extended # or qbx_core / qb-core ensure np_prophandler # doors and keypad props ensure np_inventory # optional: items and stash locks ensure np_hud # optional ensure np_phone # optional: Passwords app ensure np_admin # optional: permissions, settings, staff tools ensure np_passwords ensure my_apartments # every resource that registers locksadd_acelines: staff get thenp_passwords.*nodes in np_admin (see Permissions). - Configure
shared/config.lua(Configuration): static locks, OTP apps and the warrant jobs at least.
Start order
Bridges are picked once, at start. RegisterLock calls made before np_passwords finished booting are queued and run
after it loaded the saved locks, so resources that start at the same time are fine. The phone app, the np_menu
options, the np_inventory items and the stash hooks are registered again when those resources restart.
Without the convar
If np_passwords:secret is missing (or shorter than 16 characters), np_passwords generates a random key once, stores
it in the np_pw_meta table and prints a warning at every start. That works, but then the key sits next to the
encrypted data in the same database. Set the convar.
Permissions ​
np_passwords uses no ACE. Every check is a permission node, managed in np_admin: grant the
nodes to an np_admin group or a single player (wildcards like np_passwords.* work, an explicit deny wins).
| Node | Grants |
|---|---|
np_passwords.admin |
Staff actions Reset nearest lock, List nearby locks, Wipe keychain |
np_passwords.locks |
/pwlock add / remove / reset / list, the staff actions Set lock code and Remove lock, and managing every lock (change code, guest codes) as if they owned it |
np_passwords.reveal |
Lock owner and access log view. Registered so it shows in the permission matrix; no tool checks it yet |
Without np_admin running, only these pass a check:
- the server console;
- the identifiers in the convar
np_admin_fallback(set np_admin_fallback "license:abc…,discord:123…"); - on es_extended, the ESX groups in
np_admin_fallback_groups(defaultadmin,superadmin).
Tables ​
| Table | Holds |
|---|---|
np_pw_meta |
Key / value store: the generated key when the convar is missing, the /pwlock id counter |
np_pw_locks |
Every persisted lock: type, rules, bcrypt hash, crack time, owner, coords, tries, lockout, door, meta, fail counter, leak flag |
np_pw_keychain |
What each character knows: label, username, encrypted secret, autofill flag, source (typed, created, shared, note, guest, grant, manual), uses, soft delete |
np_pw_vaults |
Gang (gang:<id>), job (job:<name>) and custom (v:<n>) vaults |
np_pw_vault_members |
Members of custom vaults with role owner / editor / viewer |
np_pw_vault_items |
Shared entries: encrypted secret, minimum rank, flagged |
np_pw_guest |
Guest codes (hash, uses left, expiry) |
np_pw_otp |
2FA secrets per character and app (encrypted) |
np_pw_log |
Access log: lock, character, method (typed, autofill, crack, guest, warrant, verify, set, reveal), result, time. Never the secret |
Check it works ​
- Join with an account that has
np_passwords.locks(or is in the fallback) and run/pwlock add pin Test door 1234. The chat answersLock admin:1 created, code: 1234. - Stand there: the proximity prompt shows G Enter code. Type
1234; the keypad turns green and a Save this code? toast follows. Press Y. - Walk away and back: now E Unlock opens it with the saved code. With np_phone, the entry is in the Passwords app under Doors & safes.
/pwlock remove admin:1cleans up.
Troubleshooting ​
| Problem | Fix |
|---|---|
| Blank UI, nothing visible | Build the NUI (web/dist missing) |
Console: convar np_passwords:secret is not set |
Add set np_passwords:secret "…" to server.cfg (16+ characters) |
| Saved codes show as empty or autofill fails after a move | The secret changed. Restore the old np_passwords:secret value |
| No proximity prompt | The lock has no coords, or you are further than Config.Locks.promptDistance (1.6 m) / the lock's radius |
| "You are too far away" | Attempts are allowed within the lock's radius + 2 m |
| "This lock has no code yet" | Register it with code or generate = true, or let the owner set one with Create |
| No items | np_inventory: Config.Items.register is false. ox / qb: add the items (step 5) |
| Code breaker does nothing | Config.Crack.enabled, the lock is crackable = false, or the player lacks Config.Crack.item |
/pwlock says no permission |
Grant np_passwords.locks in np_admin (without np_admin: np_admin_fallback or an ESX group from np_admin_fallback_groups) |
| The prompt opens behind another UI | Raise Config.ZIndex (default 1000) |