Kartik Scripts

Safe & PIN Access

Safe & PIN Access

A safe is a furniture piece that stores items and can be locked behind a keypad PIN. Managers set the PIN; anyone who knows it can open the safe without needing property access.


What is a safe?

  • A furniture piece with feature.type == 'safe' (currently the prop_ld_int_safe_01 model). Place it like any storage piece in the furniture modeler.
  • By default a safe is manager-only (like any storage). The PIN is an optional extra that grants access to non-managers who know the code.

Setting / clearing a PIN

  • A manager opens the safe and sets a PIN (or clears it). Managers always bypass the PIN via their normal access.
  • PIN length is Config.Safe.PinLength (4 digits).

Opening with a PIN

  • A non-manager walks up to the safe, presses E, and enters the PIN on a masked numeric keypad.
  • Wrong entries count toward Config.Safe.MaxAttempts (5); exceeding it locks the keypad for Config.Safe.LockoutSeconds (300 s).

Security model

PINs are stored hashed and peppered, never in plaintext, never sent to clients.

  • Hash = SHA-256(pepper + salt + pin), computed server-side in pure Lua (with a NIST self-test at boot).
  • The pepper is a server-only secret in shared/security_server.lua (Config.Safe.Pepper), change it to a long random string before going live.
  • Shared tunables (PinLength, MaxAttempts, LockoutSeconds) live in shared/security.lua.

Changing the pepper invalidates every existing safe PIN. Set it once, keep it secret.

Notes

  • A safe with a PIN is inviolable without the PIN or manager rights, brute force is capped by the lockout. (A cracking minigame is intentionally not included.)
  • Orphaned PINs (safe removed) are cleaned up automatically when the layout is saved.
  • Buying an interior layout that replaces furniture also clears the target property's safe PINs.

On this page