🆔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

Installation

  1. Download and extract the resource to your resources folder

  2. Add ensure idcard to your server.cfg

  3. Make sure you have the required dependencies installed

  4. Configure the resource (see Configuration section)

Configuration

Main Configuration (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)

⚠️ This file is loaded server-side only for security!

Export Type

Commands

/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]

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

Closes the currently opened ID card.

/takePicture

Opens 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

Opens an ID card for a player.

Parameters:

  • sourcePlayerId (number): Server ID of the player showing the card

  • targetPlayerId (number): Server ID of the player viewing the card

  • cardType (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_licenses table

Weapon License

  • Shows: Same as passport + Weapon license

  • Requires: Weapon license in user_licenses table

Cayo Card

  • Shows: Same as passport + Cayo license

  • Requires: Cayo license in user_licenses table

Photo System

Taking a Photo

  1. Use /takePicture command or trigger screenshot:takePicture event

  2. Player is teleported to photo studio

  3. Photo is captured using screenshot-basic

  4. Photo is uploaded to Discord/FiveManage (configured in shared/api.lua)

  5. Photo URL is stored in FiveM KVP and displayed on all cards

Photo Storage

  • Photos are stored in FiveM Key-Value Pairs (KVP) as cardId

  • Photo 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 identifier

  • firstname (string): Player first name

  • lastname (string): Player last name

  • dateofbirth (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 match users.identifier)

  • type (string): License type (must match PHOTO.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_licenses table

  • Job 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 player

  • Automatically 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.Licenses match exactly with your database

  • Verify owner field format matches your ESX setup

  • Check server console for cache errors

  • Try refreshing the cache: TriggerEvent("idcard:refreshCache", source)

Photo doesn't upload

  • Verify API credentials in shared/api.lua

  • Check that screenshot-basic resource is started

  • Check 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 emote mode, ensure emote script is installed

  • If using custom mode, verify animation dictionaries are loaded

  • Check PHOTO.Config.ShowCardAnimation.enabled is true

Last updated