# 3 · Vehicle Keys & Locking

Understand key types, lock state and the built-in player commands.

# Key Types

Nord Vehicle Keys uses different key types for different access lifecycles.

| Key type | Typical use | Persistence |
|---|---|---|
| `owner` | Player-owned vehicle | Permanent |
| `shared` | Shared access | Permanent or timed |
| `temporary` | Rentals/scripts | Timed |
| `session` | Stolen/NPC vehicle | Temporary session |
| `admin` | Administrative grant | Permanent until removed |

When a physical key item is issued, metadata includes at least:

```lua
{
    plate = 'ABC123',
    keyType = 'owner',
    expiresAt = 0,
    sessionToken = ''
}
```

Session keys use a session token that is validated server-side and cannot be reused by another player connection.


# Locking Controls

Default lock controls:

```text
L                  Toggle current/nearest vehicle lock
/vehiclelock       Toggle current/nearest vehicle lock
/lockvehicle       Lock current/nearest vehicle
/unlockvehicle     Unlock current/nearest vehicle
```

The lock key is configurable through `Config.Keybinds.Lock` and FiveM key mappings.

Lock state is synchronized using server-controlled vehicle state bags. This allows all clients to apply the same logical lock state while the server remains authoritative for access validation.


# Admin Key Commands

Administrative key commands require the ACE configured in `Config.Security.AdminAce`.

Default ACE:

```cfg
add_ace group.admin nord.vehiclekeys.admin allow
```

Commands:

```text
/adminkey [server id] [plate]
/adminkeyremove [server id] [plate]
```

`/adminkey` issues administrative access and synchronizes the matching physical key item when physical keys are active.

`/adminkeyremove` removes stored access and the matching physical key item.