🆔ID CARD
A comprehensive ID card system for ESX Legacy servers featuring passport, driver license, weapon license, and custom card types. Includes photo capture system with Discord/FiveManage integration.







Features
Multiple Card Types: Passport, Driver License, Weapon License, Cayo Card, Police Badge, Job Badges
Photo System: Take and store player photos for ID cards
Show Cards: Display cards to nearby players with animations (automatically finds closest player)
Export System: Easy integration with other resources
Secure API: Server-side credential protection for image uploads
Customizable: Extensive configuration options
Job Badge System: Automatic job detection and custom badge display for all jobs
Requirements
esx_license (for licenses)
screenshot-basic (for photo capture)
Installation
Download and extract the resource to your
resourcesfolderAdd
ensure idcardto yourserver.cfgMake sure you have the required dependencies installed
Configure the resource (see Configuration section)
Configuration
Main Configuration (shared/_main.lua)
shared/_main.lua)Commands
Show Card Distance
Card Animation
License Configuration
Important: The dbName must match EXACTLY the license types in your user_licenses table.
API Configuration (shared/api.lua)
shared/api.lua)⚠️ This file is loaded server-side only for security!
Export Type
Commands
/openCard [type]
/openCard [type]Opens your own ID card.
Types: passport, driver, weapon, cayo, police, job, or any configured job name
Examples:
/openCard- Opens passport (default)/openCard driver- Opens driver license/openCard weapon- Opens weapon license/openCard cayo- Opens cayo card/openCard police- Opens police badge (if you're a police officer)/openCard job- Opens your job badge (automatically detects your job)/openCard mechanic- Opens mechanic badge (if you're a mechanic)
/showCard [type]
/showCard [type]Shows your ID card to the closest player within 3 meters.
Types: passport, driver, weapon, cayo, police, job, or any configured job name
Examples:
/showCard driver- Shows driver license to nearby player/showCard weapon- Shows weapon license to nearby player/showCard police- Shows police badge to nearby player (if you're a police officer)/showCard job- Shows your job badge to nearby player (automatically detects your job)/showCard mechanic- Shows mechanic badge to nearby player (if you're a mechanic)
/closeCard
/closeCardCloses the currently opened ID card.
/takePicture
/takePictureOpens the photo capture menu to take a new ID photo.
Note: This command can be disabled by setting PHOTO.Config.EnableTakePicture = false
Exports
Client-Side Exports
GetCardId()
Returns the URL of the player's ID card photo.
Returns: string - Photo URL or nil if no photo exists
Example:
OpenCard(cardType)
Opens a specific card type for the current player.
Parameters:
cardType(string, optional): Card type ("passport","driver","weapon","cayo","police","job", or any configured job name). Defaults to"passport".If
"job"is specified, automatically detects the player's current job and shows the corresponding badge.
Returns: boolean - true if successful, false if invalid card type
Examples:
ShowCard(cardType, targetPlayerId)
Shows a card to another player. Automatically finds the closest player within configured distance if no target is specified.
Parameters:
cardType(string, optional): Card type ("passport","driver","weapon","cayo","police","job", or any configured job name). If only one parameter is provided, it's treated as cardType and automatically finds closest player.If
"job"is specified, automatically detects the player's current job and shows the corresponding badge.
targetPlayerId(number, optional): Target player's server ID. If not provided, automatically finds closest player within configured distance (default: 3 meters).
Returns: boolean - true if successful, false if no player found or invalid card type
Examples:
Server Events
idcard:open
idcard:openOpens an ID card for a player.
Parameters:
sourcePlayerId(number): Server ID of the player showing the cardtargetPlayerId(number): Server ID of the player viewing the cardcardType(string, optional): Card type ("passport","driver","weapon","cayo"). Defaults to"passport".photoUrl(string, optional): Photo URL. If not provided, uses stored photo.
Example:
Usage Examples
Basic Menu Integration
Police Script Example
Vehicle Script Example
RageUI Menu Integration Example
Using Exports with Job Cards
Custom Photo Check
Card Types
Passport
Shows: Firstname, Lastname, Date of Birth, Sex, Height, Nationality
Always available (no license required)
Driver License
Shows: Same as passport + Driver licenses (car, bike, boat, truck, etc.)
Requires: At least one driver license in
user_licensestable
Weapon License
Shows: Same as passport + Weapon license
Requires: Weapon license in
user_licensestable
Cayo Card
Shows: Same as passport + Cayo license
Requires: Cayo license in
user_licensestable
Photo System
Taking a Photo
Use
/takePicturecommand or triggerscreenshot:takePictureeventPlayer is teleported to photo studio
Photo is captured using
screenshot-basicPhoto is uploaded to Discord/FiveManage (configured in
shared/api.lua)Photo URL is stored in FiveM KVP and displayed on all cards
Photo Storage
Photos are stored in FiveM Key-Value Pairs (KVP) as
cardIdPhoto URL is retrieved on resource start
Photo URL is sent with card data when opening cards
Photo Upload Services
Discord Webhook
Uploads photo to Discord channel via webhook
Returns Discord attachment URL
Configure webhook URL in
shared/api.lua
FiveManage API
Uploads photo to FiveManage image hosting
Requires API key
Configure API key and URL in
shared/api.lua
Security Note: API keys and webhooks are stored server-side only in shared/api.lua to prevent client-side access.
Database Structure
Required Tables
users table
Must contain:
identifier(string): Player identifierfirstname(string): Player first namelastname(string): Player last namedateofbirth(string): Date of birth (format: DD/MM/YYYY or DD-MM-YYYY)sex(string): "m" or "f"height(number): Height in cm
user_licenses table
Must contain:
owner(string): Player identifier (must matchusers.identifier)type(string): License type (must matchPHOTO.Config.Licenses[].dbName)
Important: The owner field format must match your ESX configuration (usually char1:identifier or just identifier).
Cache System
The resource uses a server-side caching system to optimize database queries and improve performance.
How It Works
Automatic Caching: Player data (identity, licenses, job) is cached when first accessed
Cache Lifecycle: Cache is created when a player opens/shows a card and persists until the player disconnects
Cache Refresh: Cache is automatically refreshed when needed (e.g., when player data changes)
Memory Management: Cache is automatically cleared when a player disconnects
Cache Contents
The cache stores:
User Data: Firstname, lastname, date of birth, sex, height
Licenses: All licenses from
user_licensestableJob Data: Current job name, label, grade, and grade information
Manual Cache Refresh
If you need to refresh a player's cache manually (e.g., after granting a license), you can trigger:
Cache Events
idcard:refreshCache- Refreshes the cache for a specific playerAutomatically triggered on player disconnect to clean up memory
Performance Benefits
Reduces database queries by caching player data
Improves response time when opening/showing cards
Automatically manages memory by clearing cache on disconnect
Troubleshooting
Card doesn't show licenses
Check that license types in
PHOTO.Config.Licensesmatch exactly with your databaseVerify
ownerfield format matches your ESX setupCheck server console for cache errors
Try refreshing the cache:
TriggerEvent("idcard:refreshCache", source)
Photo doesn't upload
Verify API credentials in
shared/api.luaCheck that
screenshot-basicresource is startedCheck server console for upload errors
Card doesn't open
Ensure ESX is properly loaded
Check that player data is available
Verify card type is valid (
passport,driver,weapon,cayo)
Animation doesn't play
If using
emotemode, ensure emote script is installedIf using
custommode, verify animation dictionaries are loadedCheck
PHOTO.Config.ShowCardAnimation.enabledistrue
Last updated