> For the complete documentation index, see [llms.txt](https://code-after-sex.gitbook.io/script-documentation/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://code-after-sex.gitbook.io/script-documentation/cas-duel-arena-system/installation.md).

# Installation

Install the RedM Duel & Arena System duel script on VORP, RSG Core or standalone. server.cfg order, admin permission, Steam avatars, updating.

## Before you start

You need:

* A RedM server running **VORP Core**, **RSG Core**, or no framework at all.
* Access to `server.cfg`.
* Optional: [oxmysql](https://github.com/overextended/oxmysql). With it, duel data is stored in MySQL. Without it, the resource uses its own KVP store and still works.

You do not need Node.js. The menu ships already built in `web/dist`. You only need Node if you want to [edit the interface](/script-documentation/cas-duel-arena-system/interface.md).

## 1. Place the folder

Copy `cas-duel` into your `resources` folder.

{% hint style="warning" %}
Keep the folder name `cas-duel`. When the resource runs without oxmysql, its saved data belongs to the resource name, so renaming the folder later starts everyone from scratch.
{% endhint %}

## 2. Add it to server.cfg

Start it **after** your framework and oxmysql:

```cfg
ensure oxmysql
ensure vorp_core
ensure cas-duel
```

On RSG Core use `ensure rsg-core` instead of `ensure vorp_core`. On a standalone server leave the framework line out.

If the framework or oxmysql is still starting when `cas-duel` loads, the resource waits up to 15 seconds for it before falling back.

## 3. Grant the admin permission

```cfg
add_ace group.admin duels.admin allow
```

Players do not need any permission to duel. This one is only for `/duel_admin`. See [Permissions](/script-documentation/cas-duel-arena-system/permissions.md).

## 4. Optional: Steam profile pictures

Player portraits in the menu use Steam profile pictures when a Steam Web API key is set:

```cfg
set steam_webApiKey "YOUR_STEAM_WEB_API_KEY"
```

Without a key, players get the game's default silhouette. Nothing else is affected.

## 5. Start the server

The database tables (`duel_profiles`, `duel_history`, `duel_meta`) are created on the first start. There is no SQL file to import.

Watch your console. You should see:

```
[cas-duel] Framework: VORP Core
[cas-duel] Storage: oxmysql
[cas-duel] Loaded 0 profiles
[cas-duel] Ready
```

If the framework line does not match the framework you run, set it by hand in `config.lua`:

```lua
Config.Framework = 'vorp'   -- 'auto' | 'vorp' | 'rsg' | 'standalone'
```

## 6. Check it in game

Join with a character loaded and type:

```
/duels
```

The duel menu opens on the **Challenge** tab. Nearby players appear in the list. If you see "Pick a character first.", your character has not finished loading yet.

## 7. Check your arenas

The included arenas were measured on the default map. If your server has custom buildings, walls or MLOs on those streets, measure them again with the arena tool. It takes a minute per arena. See [Arenas](/script-documentation/cas-duel-arena-system/arenas.md).

## Updating

1. Stop the resource.
2. Replace every file except `config.lua`.
3. Compare your `config.lua` against the new one for any settings that were added.
4. Start the resource.

{% hint style="danger" %}
Never delete the `duel_profiles`, `duel_history` or `duel_meta` tables when updating. Ratings, match history, tournament brackets and money owed to offline players live there.
{% endhint %}
