Skip to content

Events & commands ​

Server events ​

server

Local server events (AddEventHandler), fired with TriggerEvent after np_passwords did the work. None of them carries a secret.

Event Arguments Fired when
np_passwords:unlocked src, lockId, method A lock, a verifier login (lockId = 'verify:<name>') or a 2FA prompt ('otp:<app>') was opened
np_passwords:failed src, lockId, triesLeft A wrong try on a lock. triesLeft = 0 on the try that starts the lockout
np_passwords:lockout lockId, src, fails The lock locked out after fails wrong tries
np_passwords:codeChanged lockId, bySrc The code was set or rotated (SetCode, the generator, the phone app, staff). bySrc is nil for scripts
np_passwords:leaked lockId, src An outsider opened the lock by typing or cracking. See Leaks
np_passwords:dispatch lock, src, coords A lockout on a lock with dispatch = true (or Config.Locks.dispatch). See below

method is one of:

Method How
typed Typed by hand
autofill A saved keychain entry or vault item (TAB, proximity E, <np-password>)
guest A guest code
crack The code breaker
verify A verifier login, typed
otp A typed 2FA code
lua
AddEventHandler('np_passwords:unlocked', function(src, lockId, method)
  if lockId:sub(1, 5) == 'bank:' and method == 'crack' then
    TriggerEvent('my_heists:vaultCracked', src, lockId)
  end
end)

AddEventHandler('np_passwords:leaked', function(lockId, src)
  print(('[security] %s opened %s without knowing the code'):format(GetPlayerName(src), lockId))
end)

Dispatch ​

Off by default. Turn it on per lock (dispatch = true in RegisterLock) or for every lock (Config.Locks.dispatch). np_passwords only fires the event; hook your dispatch resource to it:

lua
-- lock = public lock info (id, label, icon, type, coords, …), coords = the player's position
AddEventHandler('np_passwords:dispatch', function(lock, src, coords)
  exports.my_dispatch:Alert({
    code = '10-90', title = 'Keypad tampering', message = lock.label,
    coords = coords, jobs = { 'police' },
  })
end)

Client event ​

client

Event Arguments Fired when
np_passwords:client:unlocked lockId, method This player opened a registered lock (not verifier or 2FA prompts)
lua
RegisterNetEvent('np_passwords:client:unlocked', function(lockId, method)
  if lockId == 'apt12:front' then PlaySoundFrontend(-1, 'Door_Open', 'Lester1A_Sounds', true) end
end)

Events np_passwords listens to ​

Event From Effect
esx:playerLoaded / esx:playerLogout / esx:setJob es_extended Character load and unload, job change
QBCore:Server:PlayerLoaded / OnPlayerUnload / OnJobUpdate / SetDuty qb-core, qbx_core Same
np_character:loaded / np_character:unloaded np_character Same (standalone)
np_gangs:server:memberLeft np_gangs Gang vault items the leaver could see are flagged for rotation
np_gangs:server:gangDissolved np_gangs Every item of the gang vault is flagged
np_gangs:server:memberJoined np_gangs The new member's known locks are refreshed
playerDropped FiveM Open prompts, offers, crack sessions and unlock records of that player end

A job change or a demotion flags the job vault items the player could see before. An unloaded character closes every open panel.

Net events (np_passwords:rpc, np_passwords:push, np_passwords:client:stashPrompt) are internal. See the NUI contract. The item events np_passwords:client:useBreaker (crack the nearest lock) and np_passwords:client:useWarrant (read the closest player's keychain) may be triggered from your own usable-item callback, see Bridges → Inventory; the server checks everything again.

Commands ​

Command Who What
/pwlock add <type> <label…> [code] Node np_passwords.locks Lock at your position, id admin:<n>, owner none. Without a code a random one is generated and shown
/pwlock remove <id> Node np_passwords.locks Remove a lock
/pwlock reset <id> Node np_passwords.locks Clear lockout, fail counter and the leak flag
/pwlock list Node np_passwords.locks Up to 15 locks, nearest first

The command name comes from Config.Admin.command. The server console may run remove, reset and list. See Locks → Admin commands for the details.

Staff actions (np_admin) ​

With np_admin running, these show up under Resource tools:

Action Node Target What
Reset nearest lock np_passwords.admin – Clears lockout, fails and leak flag of the nearest lock within 10 m
Set lock code np_passwords.locks – Arguments: lock id, new code. Rotates like SetCode
Remove lock np_passwords.locks – Argument: lock id
List nearby locks np_passwords.admin – Same as /pwlock list
Wipe keychain np_passwords.admin Player Deletes every keychain entry of that character

np_admin's audit log (category np_passwords) gets lock creation and removal, code changes, lockouts, leaks, cracks, warrant reads, resets and keychain wipes, never a secret.

Keys ​

Where Keys
Any prompt TAB saved code · ENTER submit · ESC close
PIN / 2FA 0–9 · Backspace
Login TAB saved login or next field · ↑ ↓ saved logins
Generator R shuffle · ← → length · ENTER save · ESC cancel
Save / update toast Y / N
Near a lock E unlock with a saved code / lock an open door · G enter code
Near someone typing H watch

The panel keys follow Config.Keys (see Configuration → Keys).