> ## 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 Redzone

> Complete Redzone installation, game-mode, hook, theme, and API reference.

> Complete Redzone installation, game-mode, hook, theme, and API reference.

`fnx-pvp-redzone` runs instanced free-for-all combat zones with loadouts, boundaries, respawns, stats, and leaderboards.

## First installation

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

ensure fnx-pvp-panel
ensure fnx-pvp-killfeed
ensure fnx-pvp-redzone
```

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

## First setup

Edit both public cfg files. Test every respawn, polygon, inventory item, return bucket, and optional map dependency.

## Client configuration

### Plugin

| Key                     | Default                         | Explanation                 |
| ----------------------- | ------------------------------- | --------------------------- |
| `Plugin.id`             | `"redzone"`                     | Unique panel plugin ID.     |
| `Plugin.labelKey`       | `"plugins.redzone.label"`       | Title locale key.           |
| `Plugin.descriptionKey` | `"plugins.redzone.description"` | Description locale key.     |
| `Plugin.icon`           | `"fa-solid fa-crosshairs"`      | Font Awesome icon.          |
| `Plugin.resource`       | `PVP_REDZONE_RESOURCE`          | Resource owning the plugin. |
| `Plugin.ui`             | `"web/dist/index.html"`         | Built NUI page.             |
| `Plugin.order`          | `35`                            | Panel sort position.        |
| `Plugin.enabled`        | `true`                          | Enables registration.       |

### Commands, runtime, death, and respawn

| Key                                | Default           | Explanation                                                                               |
| ---------------------------------- | ----------------- | ----------------------------------------------------------------------------------------- |
| `Commands.open.enabled`            | `true`            | Enables `/redzone`.                                                                       |
| `Commands.open.name`               | `"redzone"`       | Open command name.                                                                        |
| `Commands.leave.enabled`           | `true`            | Enables leave command/key.                                                                |
| `Commands.leave.name`              | `"leaveredzone"`  | Leave command name.                                                                       |
| `Commands.leave.key`               | `"F6"`            | Default leave key.                                                                        |
| `Commands.leave.keyDescription`    | `"Leave Redzone"` | FiveM keybind label.                                                                      |
| `Runtime.closePanelOnJoin`         | `true`            | Closes the panel on join.                                                                 |
| `Runtime.deathEvents`              | `true`            | Enables built-in death-event handling. Disable when a custom detector is the only source. |
| `Runtime.invincible.enabled`       | `true`            | Master switch for transition invincibility.                                               |
| `Runtime.invincible.beforeRound`   | `true`            | Protects before combat begins.                                                            |
| `Runtime.invincible.afterRound`    | `true`            | Protects after combat/round end.                                                          |
| `Runtime.outOfArea.timeoutSeconds` | `5`               | Seconds allowed outside the polygon.                                                      |
| `Runtime.outOfArea.disableFiring`  | `true`            | Blocks firing while outside.                                                              |
| `Runtime.returnCoords`             | `nil`             | Optional client return `vec4`.                                                            |
| `ClientCfg.Death`                  | `{}`              | Overrides panel death defaults; empty inherits all defaults.                              |
| `Respawn.mode`                     | `"area"`          | Respawn selection strategy; `area` uses configured mode spawns.                           |

### Client hooks

| Key                               | Arguments         | Called when                                              |
| --------------------------------- | ----------------- | -------------------------------------------------------- |
| `Events.OnRedzoneJoin`            | `payload`         | Joining; default code equips the ox\_inventory weapon.   |
| `Events.OnRedzoneLeave`           | none              | Leaving.                                                 |
| `Events.OnRedzoneHudOpen`         | `payload`         | HUD opens.                                               |
| `Events.OnRedzoneHudUpdate`       | `payload`         | HUD changes.                                             |
| `Events.OnPlayerDeadOnRedzone`    | `payload, mode`   | Local player death is accepted.                          |
| `Events.OnPlayerRespawnOnRedzone` | `mode`            | Local respawn; default code equips ox\_inventory weapon. |
| `Events.OnGameEventTriggered`     | callback or `nil` | Optional raw game-event callback.                        |

## Server configuration

| Key                                   | Default          | Explanation                                                                                 |
| ------------------------------------- | ---------------- | ------------------------------------------------------------------------------------------- |
| `Inventory.enabled`                   | bridge-dependent | Enables inventory handling.                                                                 |
| `Inventory.keepInventory`             | `false`          | Disables Redzone inventory/loadout management and lets players keep items.                  |
| `Inventory.mode`                      | `"auto"`         | `auto`, `bridge`, or `native`.                                                              |
| `Inventory.weaponMetadata.enabled`    | `true`           | Gives weapon ammo/components inside weapon metadata instead of as separate inventory items. |
| `Inventory.weaponMetadata.durability` | `10000`          | Durability value written to weapon metadata when metadata mode is enabled.                  |
| `Inventory.weaponMetadata.ammo`       | `true`           | Stores configured ammo in weapon metadata and skips the separate ammo item grant.           |
| `Inventory.weaponMetadata.components` | `true`           | Stores configured components in weapon metadata and skips separate component item grants.   |
| `Inventory.ammoRefill.enabled`        | `true`           | Enables automatic ammo refill checks.                                                       |
| `Inventory.ammoRefill.threshold`      | `0.5`            | Refill only when current ammo is below this fraction of configured ammo.                    |
| `Inventory.ammoRefill.respawn`        | `true`           | Checks/refills ammo after Redzone respawn.                                                  |
| `Join.warning.enabled`                | bridge-dependent | Enables inventory-change warning.                                                           |
| `Join.warning.holdSeconds`            | `1`              | Confirmation hold time in seconds.                                                          |
| `Join.warning.timeoutSeconds`         | `30`             | Confirmation expiry in seconds.                                                             |
| `Redzone.returnCoords`                | `nil`            | Optional server return `vec4`.                                                              |
| `Redzone.bucketBase`                  | `60000`          | First Redzone routing bucket.                                                               |
| `Redzone.returnBucket`                | `0`              | Bucket restored on leave.                                                                   |
| `Runtime.defaultElo`                  | `0`              | Starting Redzone Elo.                                                                       |
| `Runtime.gamemodes`                   | array            | Available modes.                                                                            |

### Rewards

`ServerCfg.Rewards` controls item/account rewards. Rewards are given independently from Redzone loadouts, so they still work when `Inventory.keepInventory` is true.

| Key                                   | Explanation                                                                      |
| ------------------------------------- | -------------------------------------------------------------------------------- |
| `Rewards.kill.enabled`                | Enables rewards for every kill.                                                  |
| `Rewards.kill.items`                  | Items/accounts given on kill.                                                    |
| `Rewards.killStreaks.enabled`         | Enables killstreak rewards.                                                      |
| `Rewards.killStreaks.public`          | When false, players need command-granted access before receiving streak rewards. |
| `Rewards.killStreaks.rewards[streak]` | Rewards given when the player reaches that streak value.                         |
| `reward.item`                         | Inventory item name given through the configured inventory bridge.               |
| `reward.account`                      | Framework account name such as `bank`; requires a framework/account bridge.      |
| `reward.amount`                       | Base reward amount. It is multiplied by the player's reward multiplier.          |
| `reward.metadata`                     | Optional item metadata passed to the inventory.                                  |

### Logs

Each log category supports `enabled`, `username`, `avatar`, `webhooks`, and `embed`. `webhooks` is an array, so one category can send to multiple Discord webhooks. `embed` is a Lua function and can be fully customized per server.

| Category                | Sent when                                                                    |
| ----------------------- | ---------------------------------------------------------------------------- |
| `Logs.admin`            | Admin/internal actions such as reward permission or multiplier changes.      |
| `Logs.kills`            | A Redzone kill is recorded. On large servers this can be noisy/rate-limited. |
| `Logs.join`             | A player joins a Redzone mode.                                               |
| `Logs.exit`             | A player exits or drops from Redzone, including kills/deaths.                |
| `Logs.inventoryStored`  | A player's inventory snapshot is stored before Redzone loadout is applied.   |
| `Logs.inventoryRestore` | A player's original inventory and pending rewards are restored.              |

### Reward commands

| Key                                       | Explanation                                         |
| ----------------------------------------- | --------------------------------------------------- |
| `Commands.giveStreakRewards.active`       | Registers the streak reward access command.         |
| `Commands.giveStreakRewards.name`         | Default command name: `giveredzonestreakrewards`.   |
| `Commands.giveStreakRewards.permission`   | Permission required to use the command.             |
| `Commands.setRewardMultiplier.active`     | Registers the reward multiplier command.            |
| `Commands.setRewardMultiplier.name`       | Default command name: `setredzonerewardmultiplier`. |
| `Commands.setRewardMultiplier.permission` | Permission required to use the command.             |

### Game-mode schema

| Key              | Type                | Explanation                                     |
| ---------------- | ------------------- | ----------------------------------------------- |
| `id`             | number/string       | Unique mode ID.                                 |
| `name`           | string              | Display name.                                   |
| `description`    | string              | Menu description.                               |
| `image`          | string              | Menu image source.                              |
| `resource`       | string/array or nil | Optional required map resource names.           |
| `maxPlayers`     | number              | Mode capacity.                                  |
| `respawnPoints`  | vector4 array       | Random/available spawn positions and headings.  |
| `area.type`      | string              | Area type; defaults use `poly`.                 |
| `area.points`    | vector3 array       | Polygon vertices in boundary order.             |
| `area.thickness` | number              | Vertical polygon tolerance.                     |
| `area.debug`     | boolean             | Displays area debugging. Disable in production. |
| `respawnTime`    | number              | Death-to-respawn delay in seconds.              |
| `weapons`        | array               | Mode loadouts.                                  |

### Weapon schema

| Key                    | Explanation                                 |
| ---------------------- | ------------------------------------------- |
| `id`                   | Unique loadout ID.                          |
| `hash`                 | FiveM weapon hash.                          |
| `label`                | Human-readable name.                        |
| `ammo`                 | Ammo issued.                                |
| `components`           | GTA component hashes applied to the weapon. |
| `itemsData.weapon`     | Inventory weapon item.                      |
| `itemsData.ammo`       | Inventory ammo item.                        |
| `itemsData.components` | Inventory component items.                  |

### Server hooks

| Key                            | Arguments                                   | Called when                |
| ------------------------------ | ------------------------------------------- | -------------------------- |
| `Events.OnRedzoneJoin`         | `player, mode`                              | Player joins.              |
| `Events.OnRedzoneLeave`        | `player, mode, dropped`                     | Player leaves/disconnects. |
| `Events.OnPlayerDeadOnRedzone` | `victimPlayer, killerPlayer, payload, mode` | Death is accepted.         |
| `Events.OnPlayerKillOnRedzone` | `killerPlayer, victimPlayer, payload, mode` | Kill is accepted.          |

## Shared files

Private shared files contain internal helpers. There is no public shared cfg.

## Theme system

| Key                    | Controls                |
| ---------------------- | ----------------------- |
| `colors.panelBg`       | Main background.        |
| `colors.panelBgStrong` | Dark background.        |
| `colors.accent`        | Primary highlight.      |
| `colors.accentStrong`  | Strong highlight.       |
| `colors.text`          | Primary text.           |
| `colors.mutedText`     | Secondary text.         |
| `colors.surface`       | Card surface.           |
| `colors.surfaceStrong` | Strong card surface.    |
| `colors.border`        | Borders.                |
| `colors.overlay`       | 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.        |
| `radii.panel`          | Panel radius in pixels. |
| `radii.card`           | Card radius.            |
| `radii.control`        | Control radius.         |
| `radii.pill`           | Pill/badge radius.      |
| `fonts.body`           | Normal-text font stack. |
| `fonts.display`        | Heading font stack.     |

## Developer info

### Client exports

| Export              | Parameters        | Returns / purpose                                         |
| ------------------- | ----------------- | --------------------------------------------------------- |
| `OpenMenu`          | none              | Opens the Redzone menu.                                   |
| `CloseMenu`         | none              | Closes the Redzone menu.                                  |
| `IsInRedzone`       | none              | Returns whether the local player is currently in Redzone. |
| `SetHud`            | `payload`         | Replaces or opens the Redzone HUD data.                   |
| `ReportDeath`       | `payload`         | Reports a local Redzone death to the resource.            |
| `CanReportDeath`    | none              | Returns whether a new death report is currently accepted. |
| `HandleDamageEvent` | `eventName, args` | Passes a game damage event into Redzone death handling.   |

### Server exports

| Export                  | Parameters          | Returns / purpose                                                    |
| ----------------------- | ------------------- | -------------------------------------------------------------------- |
| `GetLeaderboardPage`    | `request`           | Returns the requested Redzone leaderboard page.                      |
| `GetLeaderboardEntries` | `limit, sortMetric` | Returns Redzone leaderboard entries with optional limit and sorting. |

## Common issues

### Immediately outside the zone

Check polygon order, Z values, and thickness; enable debug temporarily.

### Spawning inside objects

Test every `respawnPoints` entry and keep it inside the polygon.

### Loadouts fail

Verify inventory mode plus weapon, ammo, and component item names.

### Some configured weapons are not given

Each weapon is applied with its ammunition and components as one package. If a complete package does not fit, only that weapon is skipped. Other weapons are still given and the player receives one notification showing how many weapons were skipped.

### Deaths count twice

Use built-in detection or one custom reporter, and check `CanReportDeath()` first.

## 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-redzone/
|-- client/
|   |-- private/
|   |   \-- _main.lua
|   \-- public/
|       \-- main.lua
|-- locales/
|   \-- *.json
|-- server/
|   |-- private/
|   |   |-- _database.lua
|   |   |-- _events.lua
|   |   |-- _inventory.lua
|   |   |-- _main.lua
|   |   |-- _modes.lua
|   |   |-- _runtime.lua
|   |   \-- _state.lua
|   \-- public/
|       \-- main.lua
|-- settings/
|   |-- private/
|   |   |-- client/
|   |   |   \-- _cfg.lua
|   |   \-- server/
|   |       \-- _cfg.lua
|   \-- public/
|       |-- client/
|       |   \-- cfg.lua
|       \-- server/
|           \-- cfg.lua
|-- shared/
|   \-- private/
|       \-- _main.lua
|-- web/
|   \-- dist/
\-- fxmanifest.lua
```
