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

# Fnx PVP Panel

> Complete installation, death system, NPC, theme, revive, and API reference.

> Complete installation, death system, NPC, theme, revive, and API reference.

`fnx-pvp-panel` is the core profile, settings, plugin, death, and revive service used by the PVP suite.

## First installation

```cfg theme={null}
ensure oxmysql
ensure community_bridge

ensure fnx-pvp-panel
```

Start your framework, inventory, clothing, and ambulance resources before the panel so the bridge and revive auto-detection can see them.

The resource creates its required database tables automatically. You do not need to import an SQL file.

## First setup

Edit `settings/public/client/cfg.lua` and `settings/public/server/cfg.lua`. Configure access, death behavior, only the NPC sets used by your lobby, admin permissions, spawn lobby, and revive integration.

## Client configuration

### Access

| Key                     | Default            | Explanation                       |
| ----------------------- | ------------------ | --------------------------------- |
| `Access.enabled`        | `true`             | Enables panel command/key access. |
| `Access.name`           | `"pvppanel"`       | Command name without `/`.         |
| `Access.key`            | `"F7"`             | Default FiveM key mapping.        |
| `Access.keyDescription` | `"Open PVP Panel"` | Label in FiveM keybind settings.  |

### Death defaults

| Key                                | Default    | Explanation                                      |
| ---------------------------------- | ---------- | ------------------------------------------------ |
| `Death.freeze`                     | `true`     | Freezes the dead player's ped.                   |
| `Death.invisible`                  | `false`    | Controls normal/entity visibility while dead.    |
| `Death.invincible`                 | `true`     | Prevents additional damage while in death state. |
| `Death.localInvisible`             | `true`     | Hides the ped locally during death state.        |
| `Death.animation.enabled`          | `true`     | Enables the death animation.                     |
| `Death.animation.dict`             | `"dead"`   | GTA animation dictionary.                        |
| `Death.animation.name`             | `"dead_a"` | Animation clip name.                             |
| `Death.animation.flag`             | `1`        | GTA animation playback flag.                     |
| `Death.revive.framework`           | `true`     | Allows configured framework/ambulance revive.    |
| `Death.revive.native`              | `true`     | Allows native local respawn handling.            |
| `Death.timing.preDelayMs`          | `2500`     | Milliseconds before death-state setup continues. |
| `Death.timing.postFrameworkWaitMs` | `600`      | Wait after triggering framework revive.          |
| `Death.fade.enabled`               | `true`     | Enables death/respawn screen fades.              |
| `Death.fade.outMs`                 | `250`      | Fade-out duration in milliseconds.               |
| `Death.fade.inMs`                  | `250`      | Fade-in duration in milliseconds.                |

Plugin `ClientCfg.Death` tables override matching fields and inherit the rest.

### NPC action schema

`ClientCfg.PedActions` is an array. Every entry supports:

| Key                | Explanation                                                                                   |
| ------------------ | --------------------------------------------------------------------------------------------- |
| `enabled`          | Creates the NPC when true.                                                                    |
| `resource`         | One resource name or an array of acceptable/associated resources used to decide availability. |
| `coords`           | NPC `vec4`: X, Y, Z, heading.                                                                 |
| `model`            | GTA ped model name.                                                                           |
| `scenario`         | GTA scenario string or nil.                                                                   |
| `freeze`           | Freezes the NPC in place.                                                                     |
| `invincible`       | Prevents NPC damage.                                                                          |
| `interactControl`  | FiveM/GTA control ID; `38` is normally E.                                                     |
| `interactDistance` | Maximum interaction distance.                                                                 |
| `drawDistance`     | Maximum distance for prompt/NPC processing.                                                   |
| `prompt`           | Interaction text displayed to the player.                                                     |
| `weapons`          | Weapon names associated with/removed for this interaction by its runtime behavior.            |
| `blip.enabled`     | Creates the map blip.                                                                         |
| `blip.sprite`      | GTA blip sprite ID.                                                                           |
| `blip.color`       | GTA blip color ID.                                                                            |
| `blip.scale`       | Blip size multiplier.                                                                         |
| `blip.label`       | Map legend label.                                                                             |
| `action`           | Client function executed on interaction; receives the NPC config as `self`.                   |

The included list contains separate NPC groups for spawnlobby v1, v2, and v3. Disable or remove groups you do not use.

### Advertisements

| Key              | Explanation                                         |
| ---------------- | --------------------------------------------------- |
| `Ads[].id`       | Unique card ID.                                     |
| `Ads[].title`    | Card heading.                                       |
| `Ads[].icon`     | Font Awesome icon class.                            |
| `Ads[].markdown` | Markdown content, including supported links/images. |

## Server configuration

### Spawn lobby

| Key                         | Explanation                                                                                         |
| --------------------------- | --------------------------------------------------------------------------------------------------- |
| `Lobby.spawnOnPlayerLoaded` | Enables automatic lobby spawn. Default is true only when the bridge framework is `default`.         |
| `Lobby.bucket`              | Routing bucket assigned at lobby spawn.                                                             |
| `Lobby.delayMs`             | Delay after player load before teleporting.                                                         |
| `Lobby.maps`                | Candidate spawn definitions.                                                                        |
| `Lobby.maps[].forceUseThis` | Forces this candidate instead of normal resource-based selection. Enable only one forced candidate. |
| `Lobby.maps[].resource`     | Associated/accepted map resource names.                                                             |
| `Lobby.maps[].coords`       | Array of possible spawn `vec4` values.                                                              |

### Bridge events

`ServerCfg.BridgeEvents` lets standalone or custom-framework servers forward their own load/unload events into the panel/community bridge lifecycle.

| Key                                 | Explanation                                                               |
| ----------------------------------- | ------------------------------------------------------------------------- |
| `BridgeEvents.playerLoaded.active`  | Enables the custom player-loaded event forwarder.                         |
| `BridgeEvents.playerLoaded.event`   | Source event name to listen for.                                          |
| `BridgeEvents.playerLoaded.delayMs` | Optional delay before forwarding.                                         |
| `BridgeEvents.playerLoaded.source`  | Function that receives the event arguments and returns the player source. |
| `BridgeEvents.playerUnload.active`  | Enables the custom player-unload event forwarder.                         |
| `BridgeEvents.playerUnload.event`   | Source event name to listen for.                                          |
| `BridgeEvents.playerUnload.delayMs` | Optional delay before forwarding.                                         |
| `BridgeEvents.playerUnload.source`  | Function that receives the event arguments and returns the player source. |

Use this only when the normal bridge/framework load and unload events are not available.

### Command schema

Both `giveNicknameChange` and `giveImageChange` use these keys:

| Key                | Explanation                                                                         |
| ------------------ | ----------------------------------------------------------------------------------- |
| `active`           | Registers/enables the command.                                                      |
| `name`             | Command name.                                                                       |
| `help`             | Help text.                                                                          |
| `arguments`        | Command argument definitions.                                                       |
| `arguments[].name` | Argument identifier.                                                                |
| `arguments[].type` | Bridge argument type.                                                               |
| `arguments[].help` | Argument help text.                                                                 |
| `argsrequired`     | Requires supplied arguments.                                                        |
| `callback`         | Server function run by the command. Default grants nickname/avatar edit permission. |
| `permission`       | Required bridge permission, default `admin`.                                        |

| Function                                     | Explanation                                                                                                          |
| -------------------------------------------- | -------------------------------------------------------------------------------------------------------------------- |
| `ServerCfg.IsAdmin(source)`                  | Final server-side admin check. Adapt it to your permission system if bridge framework admin detection is not enough. |
| `ServerCfg.FrameworkRevive(source, payload)` | Sends the selected `REVIVE_EVENT` to one client. Replace it for a custom revive API.                                 |

## Shared files and automatic revive

`shared/public/_main.lua` selects one revive event when the panel starts. Selection priority is:

| Detected resource                   | Selected event                                                                         |
| ----------------------------------- | -------------------------------------------------------------------------------------- |
| `qbx_medical` or `qbx_ambulancejob` | `qbx_medical:client:playerRevived`                                                     |
| `esx_ambulancejob`                  | `esx_ambulancejob:revive`                                                              |
| `p_ambulancejob`                    | `p_ambulancejob/client/death/revive`                                                   |
| `brutal_ambulancejob`               | `brutal_ambulancejob:revive`                                                           |
| `ars_ambulancejob`                  | `pvp-panel:revive:ars_ambulancejob` (`ars_ambulancejob:healPlayer`)                    |
| `tk_ambulancejob`                   | `pvp-panel:revive:tk_ambulancejob` (`exports.tk_ambulancejob:revive`)                  |
| `ak47_qb_ambulancejob`              | `ak47_qb_ambulancejob:revive`                                                          |
| `ak47_ambulancejob`                 | `ak47_ambulancejob:revive`                                                             |
| `qb-ambulancejob`                   | `hospital:client:Revive`                                                               |
| `wasabi_ambulance_v2`               | `pvp-panel:revive:wasabi_ambulance_v2` (`exports['wasabi_ambulance_v2']:RevivePlayer`) |
| `wasabi_ambulance`                  | `pvp-panel:revive:wasabi_ambulance` (`exports['wasabi_ambulance']:RevivePlayer`)       |
| none detected                       | fallback `esx_ambulancejob:revive`                                                     |

Detection happens while the shared file loads. Start the medical resource before the panel or restart the panel after changing medical resources.

## Theme system

| Key                       | Explanation                                                                                                                                                   |
| ------------------------- | ------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| `colors.panelBg`          | Main panel background.                                                                                                                                        |
| `colors.panelBgStrong`    | Darker background.                                                                                                                                            |
| `colors.accent`           | Primary highlight. Use a valid CSS color including `#` for hex.                                                                                               |
| `colors.accentStrong`     | Strong highlight.                                                                                                                                             |
| `colors.text`             | Primary text.                                                                                                                                                 |
| `colors.mutedText`        | Secondary text.                                                                                                                                               |
| `colors.surface`          | Normal surface.                                                                                                                                               |
| `colors.surfaceStrong`    | Strong surface.                                                                                                                                               |
| `colors.border`           | Borders.                                                                                                                                                      |
| `colors.overlay`          | Modal overlay.                                                                                                                                                |
| `colors.success`          | Success foreground.                                                                                                                                           |
| `colors.successBg`        | Success background.                                                                                                                                           |
| `colors.danger`           | Danger foreground.                                                                                                                                            |
| `colors.dangerBg`         | Danger background.                                                                                                                                            |
| `colors.warning`          | Warning foreground.                                                                                                                                           |
| `colors.warningBg`        | Warning background.                                                                                                                                           |
| `colors.info`             | Info foreground.                                                                                                                                              |
| `colors.infoBg`           | Info background.                                                                                                                                              |
| `colors.ratingElite`      | Elite rating.                                                                                                                                                 |
| `colors.ratingMaster`     | Master rating.                                                                                                                                                |
| `colors.ratingDiamond`    | Diamond rating.                                                                                                                                               |
| `colors.ratingPlatinum`   | Platinum rating.                                                                                                                                              |
| `colors.ratingGold`       | Gold rating.                                                                                                                                                  |
| `colors.ratingSilver`     | Silver rating.                                                                                                                                                |
| `colors.ratingBase`       | Base rating.                                                                                                                                                  |
| `radii.panel`             | Panel radius in pixels.                                                                                                                                       |
| `radii.card`              | Card radius.                                                                                                                                                  |
| `radii.control`           | Control radius.                                                                                                                                               |
| `radii.pill`              | Pill radius.                                                                                                                                                  |
| `layout.width`            | Panel width in pixels.                                                                                                                                        |
| `layout.height`           | Panel height in pixels.                                                                                                                                       |
| `layout.sidebarWidth`     | Sidebar width in pixels.                                                                                                                                      |
| `notifications.position`  | Notification stack anchor: `top-left`, `top-center`, `top-right`, `center-left`, `center`, `center-right`, `bottom-left`, `bottom-center`, or `bottom-right`. |
| `notifications.offset`    | Notification offset `{ x, y }` from the selected anchor.                                                                                                      |
| `notifications.width`     | Notification width in pixels.                                                                                                                                 |
| `notifications.maxItems`  | Maximum visible notifications.                                                                                                                                |
| `notifications.gap`       | Gap between notifications in pixels.                                                                                                                          |
| `notifications.padding`   | Inner notification padding in pixels.                                                                                                                         |
| `notifications.iconSize`  | Notification icon size in pixels.                                                                                                                             |
| `notifications.closeSize` | Close button size in pixels.                                                                                                                                  |
| `notifications.colors`    | Per-type notification foreground/background colors for `success`, `error`, `warning`, and `info`.                                                             |
| `effects.logoOpacity`     | Logo opacity from 0 to 1.                                                                                                                                     |
| `fonts.body`              | Body CSS font stack.                                                                                                                                          |
| `fonts.display`           | Heading CSS font stack.                                                                                                                                       |

The current cfg values `FF1638F9` and `FF3CFBF1` are not standard CSS hex strings because they lack `#`. Use values such as `#1638F9` or an explicit `rgba()` value.

## Developer info

### Client exports

| Export                                  | Purpose                                         |
| --------------------------------------- | ----------------------------------------------- |
| `RegisterPlugin(plugin)`                | Registers a panel plugin.                       |
| `OpenPanel()`                           | Opens the main panel.                           |
| `OpenPlugin(pluginId)`                  | Opens a registered plugin.                      |
| `ClosePanel()`                          | Closes the panel.                               |
| `IsOpen()`                              | Returns panel visibility.                       |
| `GetSettings()`                         | Returns local panel settings.                   |
| `GetDeathConfig(overrides)`             | Resolves merged death configuration.            |
| `BeginDeathState(overrides)`            | Begins death state and returns setup timing.    |
| `RespawnLocalPlayer(coords, overrides)` | Performs local respawn and returns fade timing. |
| `EndDeathState(overrides)`              | Cleans up death state.                          |
| `BuildLocalDeathPayload(args)`          | Normalizes a local death payload.               |

### Server exports

| Export                    | Parameters                 | Returns / purpose                                                              |
| ------------------------- | -------------------------- | ------------------------------------------------------------------------------ |
| `OpenForPlayer`           | `source`                   | Opens the PVP panel for one server player.                                     |
| `CloseForPlayer`          | `source`                   | Closes the panel for one server player.                                        |
| `RegisterStatsProvider`   | `pluginId, provider`       | Registers a server callback that supplies panel statistics.                    |
| `RegisterRankProvider`    | `pluginId, provider`       | Registers a server callback that supplies panel rank information.              |
| `SyncPlayer`              | `source`                   | Synchronizes panel data for one connected player.                              |
| `SyncIdentifier`          | `identifier`               | Synchronizes data associated with an identifier.                               |
| `GetIdentifier`           | `source`                   | Returns the bridge/framework identifier for a player.                          |
| `GetDisplayName`          | `source`                   | Returns the player's resolved display name.                                    |
| `GetSourceFromIdentifier` | `identifier`               | Returns the connected server ID associated with an identifier, when available. |
| `GetPublicProfile`        | `identifier, fallbackName` | Returns the public profile, using the supplied fallback name when necessary.   |
| `GetSettings`             | `identifier`               | Returns stored panel settings for an identifier.                               |
| `GetStoredName`           | `identifier, fallbackName` | Returns the stored custom name or the fallback.                                |
| `SetStoredName`           | `identifier, displayName`  | Saves a display name for an identifier.                                        |
| `FrameworkRevive`         | `source, payload`          | Runs the configured server revive function for one player.                     |

### Shared exports

| Export           | Parameters | Returns / purpose                                                 |
| ---------------- | ---------- | ----------------------------------------------------------------- |
| `GetReviveEvent` | none       | Returns the revive event selected when the Panel resource loaded. |

## Common issues

### Panel does not open

Check start order, `Access.enabled`, command name, and the player's FiveM key mapping.

### Wrong medical event is selected

Start the intended medical resource before the panel. When multiple supported resources run, the first match in the documented priority wins.

### NPC is missing

Check enabled state, resource requirements, coordinates, model, and draw distance.

### Theme accent is ignored

Use valid CSS strings. Add `#` to hexadecimal values.

## Common folders

| Path                             | What it is for                                                                       |
| -------------------------------- | ------------------------------------------------------------------------------------ |
| `fxmanifest.lua`                 | FiveM manifest. It loads the resource files in the correct order.                    |
| `settings/public/client/cfg.lua` | Client settings that server owners are expected to edit.                             |
| `settings/public/server/cfg.lua` | Server settings that server owners are expected to edit.                             |
| `settings/private/**/_cfg.lua`   | Internal/default settings. Do not edit unless you are modifying the resource itself. |
| `client/public/*.lua`            | Public client API files and safe integration files.                                  |
| `client/private/*.lua`           | Internal client runtime code.                                                        |
| `server/public/*.lua`            | Public server API files and exports.                                                 |
| `server/private/*.lua`           | Internal server runtime code.                                                        |
| `shared/public/*.lua`            | Shared public data or integration constants.                                         |
| `shared/private/*.lua`           | Shared internal helpers loaded by the resource.                                      |
| `locales/*.json`                 | Locales for ui and game.                                                             |
| `web/dist/`                      | Built NUI files used in-game. Do not edit these by hand.                             |

```txt theme={null}
fnx-pvp-panel/
|-- bridge/
|   |-- client.lua
|   \-- server.lua
|-- client/
|   |-- private/
|   |   \-- _main.lua
|   \-- public/
|       |-- death.lua
|       |-- deathstate.lua
|       \-- main.lua
|-- locales/
|   \-- *.json
|-- server/
|   |-- private/
|   |   \-- _main.lua
|   \-- public/
|       \-- main.lua
|-- settings/
|   |-- private/
|   |   |-- client/
|   |   |   \-- _cfg.lua
|   |   \-- server/
|   |       \-- _cfg.lua
|   \-- public/
|       |-- client/
|       |   \-- cfg.lua
|       \-- server/
|           \-- cfg.lua
|-- shared/
|   |-- private/
|   |   \-- _main.lua
|   \-- public/
|       \-- _main.lua
|-- web/
|   \-- dist/
\-- fxmanifest.lua
```
