> 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-loading-screen/cas-loading-screen.md).

# CAS Loading Screen

An enhanced loading-screen experience for **RedM** (`cas-loadscreenv2`). Connecting players see their Discord/Steam identity, a music player, patch notes, server rules, social links and rotating hints — all configurable.

## Highlights

* Discord and Steam user display (avatar + name) via bot token / API key
* Built-in music player with a configurable track list
* Patch notes, server rules, social links and server hints
* Player-adjustable settings (music, clear-screen for video backgrounds, background image)
* Custom progress messages and loading events

## At a glance

|               |                                  |
| ------------- | -------------------------------- |
| Platform      | RedM                             |
| Optional APIs | Discord bot token, Steam API key |
| Resource name | `cas-loadscreenv2`               |
| Config file   | `config/config.lua`              |

## Installation

1. Purchase and download `cas-loadscreenv2` from the [store](https://cas.tebex.io/category/open-source).
2. Upload the `cas-loadscreenv2` folder to your server's `resources/` directory.
3. Add to `server.cfg`:

```
ensure cas-loadscreenv2
```

## Configuration

Everything lives in `config/config.lua`.

### Server identity

```lua
Config.ServerName = "Your Server Name"
Config.ServerLogo = "URL to your server logo"
Config.ServerDescription = "A brief description of your server"
```

### Discord & Steam

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

Config.Steam = {
    enabled = true,
    apiKey = "YOUR_STEAM_API_KEY_HERE",
    apiUrl = "https://api.steampowered.com"
}
```

Each player's Discord/Steam info is fetched from their identifiers using these keys.

### Loading screen content

```lua
Config.LoadingScreen = {
    defaultSettings = {
        clearScreen = false,          -- hide most UI (great for video backgrounds)
        playMusicOnStartup = true,
        enableMusic = true,
    },
    music = {
        tracks = {
            { id = "1", title = "Track Title", artist = "Artist Name", duration = 240, src = "URL", albumCover = "URL" },
        }
    },
    patchNotes = {
        { id = "1", title = "Title", description = "...", image = "URL", date = "YYYY-MM-DD", category = "feature" },
    },
    -- rules, socialLinks, serverHints and keybinds are configured the same way
}
```

### Progress & debug

```lua
Config.LoadingEvents = {
    progressMessages = { [0] = "Connecting..." },
    events = { ["loadProgress"] = true }
}

Config.Debug = { enabled = false }
```

## Usage

The loading screen initializes automatically when a player connects. Players adjust music, background and other options via the settings icon in the top-right corner.

## FAQ

* **Add more music tracks?** Add objects to `Config.LoadingScreen.music.tracks`.
* **Change the background?** Set `Config.LoadingScreen.defaultSettings.customBackgroundUrl`, or use the in-game settings menu.

## Support

Join the [CAS Discord](https://discord.gg/X8bTK9Stwk) or use the support channel on your product page.
