> 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-admin-panel/cas-admin-panel.md).

# CAS Admin Panel

An advanced, role-based admin panel for **RedM** servers, supporting both **VORP** and **RSGCore**. Manage players online and offline, moderate with a full action set, watch a live map, handle reports, read searchable logs and more — with Discord bot avatars and a pre-built UI.

## Highlights

* **Auto framework detection** — VORP or RSGCore, no config needed
* **5-level role hierarchy** — Helper, Moderator, Admin, Head Admin, Owner
* **Online & offline player management** — economy, inventory, bans, warnings, character edits
* **Live RDR2 map** with player markers and quick actions
* **Reports, logs (6 categories), admin chat, whitelist, teleports, spawner** and more
* **Discord bot integration** for avatars and user data (+ optional Steam fallback)
* **Pre-built UI** — no Node build required; config files kept out of escrow

## At a glance

|               |                                                   |
| ------------- | ------------------------------------------------- |
| Frameworks    | VORP + VORP Inventory · RSGCore + RSG Inventory   |
| Database      | MySQL/MariaDB + oxmysql (`yellowsql.sql`)         |
| Discord       | Bot token with Server Members Intent              |
| Optional      | Steam API key (avatar fallback), Discord webhooks |
| Resource name | `cas-admin-panel`                                 |
| Open key      | Page Down (`0x3C3DD371`) or `/adminpanel`         |

## Requirements

| Requirement | Details                                                   |
| ----------- | --------------------------------------------------------- |
| RedM Server | Any recent build (txAdmin recommended)                    |
| Framework   | VORP Core + VORP Inventory **or** RSGCore + RSG Inventory |
| Database    | MySQL/MariaDB with oxmysql installed and running          |
| Discord Bot | Token with Server Members Intent (avatars & user data)    |
| Node.js     | v16+ only if rebuilding the UI (pre-built UI included)    |

Optional: **Steam API key** (avatar fallback when no Discord avatar), **Discord webhooks** (action logging).

## Installation

### 1. Place the resource

Extract `cas-admin-panel` into your `resources` directory (a `[CAS]` folder is recommended for organization).

### 2. Import the database

Import `yellowsql.sql` into your MySQL/MariaDB database:

```bash
mysql -u root -p your_database_name < yellowsql.sql
```

This creates all required tables (admin data & logs, bans, warnings, reports, leaderboard, avatar cache, whitelist, teleports, metrics, permissions). On **RSGCore** it automatically uses `cas_bans` instead of `bans` to avoid conflicts — no manual action needed.

### 3. Configure

The main file is `config/main.lua`.

**Default owner (required):**

```lua
Config.DefaultOwners = {
    "steam:YOUR_STEAM_HEX_HERE",    -- VORP uses steam hex
    -- "license:YOUR_LICENSE_HERE", -- RSGCore uses license
}
```

**Discord bot (required):**

```lua
Config.Discord = {
    enabled = true,
    botToken = "YOUR_DISCORD_BOT_TOKEN",
    guildId = "YOUR_DISCORD_SERVER_ID",
    apiUrl = "https://discord.com/api/v10"
}
```

Create the bot on the [Discord Developer Portal](https://discord.com/developers/applications), enable **Server Members Intent**, invite it with the `bot` scope, then put your Discord server ID in `guildId`.

**Steam fallback (optional):**

```lua
Config.Steam = { enabled = true, apiKey = "" }  -- empty = skip Steam avatars
```

**General:**

```lua
Config.UseWhitelist = false
Config.DebugMode = false
Config.DefaultLanguage = "en"     -- "en" or "tr"
Config.Key = 0x3C3DD371            -- Page Down opens the panel
Config.PlayersPage = { PlayersPerPage = 25 }
```

**Webhooks (optional)** — in `config/webhooks.lua`:

```lua
Config.Discord.Webhooks = {
    player_action = "", admin_action = "", server_event = "",
    security = "", economy = "", system = "",
}
```

Leave any webhook empty to disable that category.

### 4. server.cfg

```cfg
ensure oxmysql
ensure vorp_core        # or rsg-core
ensure vorp_inventory   # or rsg-inventory
ensure cas-admin-panel
```

Start `cas-admin-panel` **after** oxmysql and your framework (auto-detected).

### 5. First launch

Connect and press **Page Down** (or type `/adminpanel`). If your identifier is in `Config.DefaultOwners`, you are logged in as **Owner** automatically.

| Problem                | Fix                                                           |
| ---------------------- | ------------------------------------------------------------- |
| Panel won't open       | Ensure `cas-admin-panel` is running                           |
| "No permission"        | Identifier in `Config.DefaultOwners` must match server output |
| No avatars             | Valid bot token + Server Members Intent enabled               |
| Database errors        | oxmysql running, `yellowsql.sql` imported into the right DB   |
| Framework not detected | Start `vorp_core` / `rsg-core` before the panel               |

## Roles & permissions

| Role       | Level | Description                                 |
| ---------- | ----- | ------------------------------------------- |
| Helper     | 1     | Basic moderation — customizable permissions |
| Moderator  | 2     | Full permissions                            |
| Admin      | 3     | Full permissions                            |
| Head Admin | 4     | Full permissions                            |
| Owner      | 5     | Full permissions — can manage all roles     |

Configured in `config/permissionconfig.lua`. Helper has individual permissions listed; Moderator and above use wildcard (`"*"`) by default.

## Commands

All commands live in `config/commands.lua` — rename, add aliases, disable, or change the permission per command.

| Command                                                                                                   | Aliases         | Description                     | Category   |
| --------------------------------------------------------------------------------------------------------- | --------------- | ------------------------------- | ---------- |
| `/adminpanel`                                                                                             | `/admin`, `/ap` | Open the admin panel            | General    |
| `/report`                                                                                                 | `/rep`          | Submit a report (all players)   | General    |
| `/myreports`                                                                                              | `/reports`      | View your reports (all players) | General    |
| `/revive`                                                                                                 | `/rev`          | Revive a player                 | Player     |
| `/heal` `/kill` `/freeze` `/goto` `/bring` `/spectate` `/respawn`                                         | —               | Core player actions             | Player     |
| `/kick` `/ban` `/warn` `/clearweapons` `/clearitems` `/clearinv`                                          | —               | Moderation                      | Moderation |
| `/fire` `/lightning` `/heaven` `/ragdoll` `/wildattack` `/drainstamina` `/handcuff` `/drunk` `/invisible` | —               | Troll actions                   | Troll      |

The sidebar order is editable in `config/navigation.lua`; the open key in `config/main.lua` (see the [FiveM/RedM key hash list](https://docs.fivem.net/docs/game-references/controls/)).

## Panel sections

Dashboard · Statistics · Players (Online) · Players (Offline) · Admins · Whitelist · Reports · Logs · Admin Chat · Live Map · Teleports · Blips · Spawner · Coords · Server Settings · Resources · Self Menu.

## Adding admins

**In-game (recommended):** open the panel → **Admins** → **Add Admin** → enter the player's Steam hex → pick a role.

**Database:**

```sql
INSERT INTO admin_data (identifier, username, `group`)
VALUES ('steam:110000xxxxxxxxx', 'PlayerName', 'admin');
```

Valid roles: `helper`, `moderator`, `admin`, `headadmin`, `owner`.

## Updating

Back up your `config/` folder, replace all files with the new version, restore `config/` (it is in `escrow_ignore`, so it is never encrypted), run any new SQL from the changelog, then restart: `ensure cas-admin-panel`.

## FAQ

* **Works with both VORP and RSGCore?** Yes — auto-detected on startup, no config needed.
* **No Discord bot?** Set `Config.Discord.enabled = false`; the panel works but without avatars/Discord usernames.
* **Change language?** `Config.DefaultLanguage = "tr"` or `"en"`; add custom files in `locales/`.
* **"oxmysql not found"?** Start oxmysql before `cas-admin-panel`.
* **Can regular players open it?** No — only identifiers in `admin_data` or `Config.DefaultOwners` have access.

## Support

Contact CAS Development through your purchase platform, or join the [CAS Discord](https://discord.gg/X8bTK9Stwk).
