Legacy Scripts

legacy-idcard

Overview

What legacy-idcard does and how it fits together.

legacy-idcard

legacy-idcard is a database-backed ID card and license system. Players use physical inventory items (ID card, driver's license, weapon license, hunting license, or any custom type created by admins) to display a styled card UI to nearby players. Police can look up, report, or revoke cards by serial number through a dedicated NUI panel, and server admins get a full React-based admin panel (/idadmin) for managing card types and issued player cards.

Key features

  • Realistic card display — using an item triggers legacy-idcard:showCard on the closest nearby player (or the user themselves), rendering a themed card with mugshot, name, DOB, sex, nationality, and citizen ID (each field toggleable per card type).
  • Serial number system — every issued card gets a unique serial number that can be looked up, reported as lost/stolen, or revoked by police via NUI (legacy-idcard:lookupSerial, legacy-idcard:reportCard, legacy-idcard:revokeBySerial).
  • Admin panel/idadmin opens a React/Vite-built NUI panel for creating, editing, and deleting card types, and for searching players and revoking their cards.
  • Exports for integration — other resources can issue, revoke, and query cards programmatically via IssueCard, RevokeCard, HasCard, and GetPlayerCards.
  • Discord webhook logging — card issuance, revocation, and card-type creation/deletion can be logged to Discord.
  • Optional cityhall sync — card status changes are mirrored into a cityhall_documents table if the legacy-cityhall resource's schema is present.

Architecture

  • Database-backed, not config-backed: card types live entirely in the legacy_card_types table and issued cards in legacy_player_cards. There are no hardcoded card types in config.lua — everything is managed through the admin panel or direct SQL/exports.
  • server/init.lua wires up the legacy-lib Framework/Inventory bridges, locale loading, admin permission checks, serial number generation, and the CardTypes cache (loaded asynchronously from the database on startup).
  • server/server.lua implements the useCard ox_inventory export, the internal item-used flow, the public card exports, and police lookup callbacks.
  • server/admin.lua implements the admin-only CRUD callbacks backing the /idadmin panel.
  • client/client.lua handles NUI display, the show-ID animation, and the admin/lookup panel bridges.
  • web/ is a separate React/Vite project that must be built to web/dist for the NUI panels to load in-game.

See Installation for setup steps, Configuration for tunable options, and Integration for exports/events you can call from your own resources.

Overview · legacy-idcard · Legacy Scripts