> ## Documentation Index
> Fetch the complete documentation index at: https://docs.shdevelopment.org/llms.txt
> Use this file to discover all available pages before exploring further.

# sh-identity: Character Identity Card System for RedM

> sh-identity adds real and fake identity cards to RedM roleplay servers. Players register, carry, and present ID documents that other scripts can verify.

The sh-identity resource gives every character on your server a physical identity card they can create, carry, and present to other players or NPCs. Cards capture configurable character fields — name, date of birth, gender, address, height, weight, and residence — and are stored per-character in the database. Authorized law enforcement can inspect another character's ID using a configurable command. sh-identity also ships with an optional Fake ID system, letting forger NPCs issue counterfeit papers for roleplay involving deception and document fraud. Other SH Development resources, such as sh-telegram, can check for a valid identity card before allowing access to their features.

## Framework Support

sh-identity supports both **VORP** and **RSG** frameworks. Set the framework in your server-side `config.lua`:

```lua config.lua theme={null}
Config.Framework = 'vorp'  -- 'auto', 'vorp', or 'rsg'
```

Setting `'auto'` (the default) lets the resource detect your running framework automatically and is recommended for most setups.

## Identity Card Fields

Each issued identity card captures the following fields from the registration form:

| Field         | Description                                                              |
| ------------- | ------------------------------------------------------------------------ |
| First name    | Character's registered first name                                        |
| Last name     | Character's registered last name                                         |
| Date of birth | Entered in `YYYY-MM-DD` format; display year can be overridden in config |
| Address       | Free-text address string (max 60 characters)                             |
| Residence     | Drop-down selection from `Config.ResidenceOptions`                       |
| Height        | Numeric value in inches (capped at `Config.CharacterLimits.maxHeight`)   |
| Weight        | Numeric value in pounds (capped at `Config.CharacterLimits.maxWeight`)   |

The birth year range available in the date picker is controlled by `Config.BirthYearStart` and `Config.BirthYearEnd`. The default range is 1845–1910 — widen it if your server uses a different era.

## Commands

sh-identity exposes several commands that you can individually enable or disable:

| Command       | Config key               | Default      | Description                                  |
| ------------- | ------------------------ | ------------ | -------------------------------------------- |
| `/idregister` | `enableRegisterCommand`  | `false`      | Opens the Registry NUI directly              |
| `/idshow`     | `enableShowCommand`      | `true`       | Shows your real ID to the nearest player     |
| `/idtest`     | `enableTestCommand`      | `true`       | Shows your real ID to yourself (for testing) |
| `/inspectid`  | `Config.Inspect.command` | `inspectid`  | Authorized jobs inspect another player's ID  |
| `/fakeidshow` | `FakeID.ShowCommand`     | `fakeidshow` | Shows your fake ID to the nearest player     |
| `/fakeidtest` | `FakeID.TestCommand`     | `fakeidtest` | Shows your fake ID to yourself               |

## How Players Obtain a Real ID

<Steps>
  <Step title="Visit a registry NPC">
    Players travel to a configured registry clerk NPC — set up in `Config.NPCs` — and press **\[R]** to interact. Default locations include Valentine and Saint Denis.
  </Step>

  <Step title="Fill in character details">
    The NUI registration form prompts the player to enter their character fields. Pre-population from the framework's character data is supported when the framework exposes it.
  </Step>

  <Step title="Pay the issuance fee">
    A configurable fee is charged on first-time registration (`Config.Fees.real.register`, default `$50`) and on updates (`Config.Fees.real.update`, default `$25`). Set `Config.Fees.enabled = false` to waive all fees.
  </Step>

  <Step title="Receive the identity card item">
    The completed card is added to the character's inventory as the usable item defined by `Config.IDItemName` (default: `id_card`). Players can use the item to display their details.
  </Step>
</Steps>

## Card Inspection

Authorized jobs can inspect another character's identity card using the `/inspectid` command (configurable). The inspector must be within `Config.Inspect.maxDistance` (default: 3.0 meters) of the target.

Configure which jobs are allowed to inspect in `config.lua`:

```lua config.lua theme={null}
Config.Inspect = {
    enabled     = true,
    command     = 'inspectid',
    maxDistance = 3.0,
    allowedJobs = {
        'marshal',
        'sheriff',
        'deputy',
        'lawman',
        'police',
        'vallaw',
    },
    -- RSG job type gate (optional)
    allowedJobTypes = {
        'leo',
    }
}
```

<Note>
  Card inspection does not require the inspecting player to hold their own identity card — only the character being checked needs to have a registered card.
</Note>

## Fake ID System

sh-identity includes a complete fake identity system gated behind a separate forger NPC. Fake IDs use a different inventory item (`Config.FakeID.ItemName`, default: `fake_id`) and separate fees (`Config.Fees.fake.register`, default `$100`).

Forger NPCs are configured in `Config.FakeID.NPCs` and have no map blip by default, keeping their location hidden for roleplay purposes. Players with a fake ID can use `/fakeidshow` to present their forged papers to nearby players.

```lua config.lua theme={null}
Config.FakeID = {
    enabled      = true,
    ItemName     = 'fake_id',
    ShowCommand  = 'fakeidshow',
    TestCommand  = 'fakeidtest',
    UseNPCs      = true,
    NPCs = {
        {
            pedModel   = 'MP_DE_U_M_M_VANHORN_01',
            coords     = { 2845.91, -1130.72, 46.38, 20.54 }, -- Saint Denis Slums
            promptText = 'Press [R] to speak with Forger',
            blip = { enabled = false },
        },
    }
}
```

## Integration With Other Resources

sh-identity exposes a server-side integration through `Config.IdentityLink` so that resources like sh-licenses can pull verified identity data directly from sh-identity records rather than re-collecting it:

```lua config.lua theme={null}
Config.IdentityLink = {
    enabled              = true,
    provider             = 'sh-identity',
    requireRealId        = false,   -- block license purchase if no real ID exists
    lockPrefilledFields  = true,    -- prevent editing synced fields in dependent UIs
    fallbackToCharacter  = true,    -- use framework character data if no real ID found
}
```

Resources in the SH Development suite that support this check include:

* **sh-telegram** — gate telegraph office access behind a valid card by setting `Config.UseSH_Identity = true`
* **sh-licenses** — pre-fill identity fields on license issuance from sh-identity records

<Tip>
  Run sh-identity early in your `server.cfg` ensure order so that dependent resources can safely read its data on first load.
</Tip>

## Installation

<Steps>
  <Step title="Add the resource">
    Copy the `sh-identity` folder into your server's `resources` directory.
  </Step>

  <Step title="Add to server.cfg">
    Ensure sh-identity after your framework and before any resource that depends on it:

    ```cfg server.cfg theme={null}
    ensure vorp_core    # or rsg-core
    ensure sh-identity
    ensure sh-telegram  # example dependent resource
    ensure sh-licenses  # example dependent resource
    ```
  </Step>

  <Step title="Import the SQL file">
    Run `sql.sql` from the resource folder against your database to create the character identity records table.
  </Step>

  <Step title="Register inventory items">
    Register both `id_card` and `fake_id` as usable items in your framework's item registry. Item definition templates are provided in the `items/` folder of the resource.
  </Step>

  <Step title="Configure">
    Open `config.lua` to set your framework, fees, residence options, birth year range, NPC locations, and optional Discord webhook URL. Add or remove entries from `Config.Inspect.allowedJobs` to match your server's law enforcement job names.
  </Step>

  <Step title="Restart and test">
    Start the resource, visit a registry clerk NPC, and complete registration. Use `/idshow` to confirm the card displays correctly to a nearby character.
  </Step>
</Steps>

<Warning>
  The `Config.IDItemName` value (default: `id_card`) must match the item name registered in your framework's item registry exactly. A mismatch will prevent the card from being added to inventory on registration.
</Warning>
