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

# CAS Notification

`cas-notification` is a modern, NUI-based notification system for **RedM**. Built with a React + TypeScript frontend and a lightweight Lua client, it shows stylish, animated notifications and is framework-agnostic — use it with any framework or none.

## Highlights

* RDR2-styled **success / error / info** notifications
* Optional sound effects and progress bars
* **Sticky** (no-timeout) notifications and click-to-dismiss
* Left/right alignment and top/bottom stacking
* Concurrency limit (up to 4 on screen at once)
* Exports API + client event, plus a test command

## At a glance

|               |                                                 |
| ------------- | ----------------------------------------------- |
| Platform      | RedM                                            |
| Framework     | Any (or none)                                   |
| Resource name | `cas-notification`                              |
| Config        | `config/client_config.lua`, `config/locale.lua` |

## Installation

1. Place `cas-notification` in your `resources` folder.
2. Add `ensure cas-notification` to your `server.cfg`.

There is no server-side Lua — everything is client-side and NUI.

## Configuration

### Client — `config/client_config.lua`

```lua
Config = {
    align = "left",           -- "left" or "right"
    testCommand = "Notifications",
    enableTestCommand = true,
}
```

Icons come from the `react-icons` Font Awesome 6 set — use the exact component names (e.g. `FaSmoking`, `FaHammer`) as the `icon` value.

### Locale — `config/locale.lua`

```lua
Locale = "en"
Locales = {
    ["en"] = { ["success"] = "Success", ["error"] = "Error", ["info"] = "Info" },
    ["fr"] = { ["success"] = "Succes", ["error"] = "Erreur", ["info"] = "Info" },
}
```

Add languages by extending `Locales` and changing `Locale`.

## Lua API (client exports)

```lua
exports["cas-notification"]:addNotification(message, notifType, duration, opts)
exports["cas-notification"]:successNotification("Operation successful", 4000)
exports["cas-notification"]:errorNotification("Something went wrong", 5000)
exports["cas-notification"]:infoNotification("Just so you know", 4000)
```

`addNotification` accepts a string (plus type/duration/opts) or a full payload table. You can also trigger via event:

```lua
TriggerEvent("cas-notification:client:addNotification", message, notifType, duration, opts)
```

### Payload options

`message`, `type` (`success`/`error`/`info`), `title`, `timeout` (ms), `sticky`, `playSound`, `soundVolume` (0–1, default 0.1), `progressBar`, `allowClickDismiss`, `align` (`left`/`right`), `position` (`top`/`bottom`), `meta`.

Default timeouts: success 4000–5000 ms, error 6000–7000 ms, info 5000–6000 ms.

```lua
exports["cas-notification"]:addNotification("You do not have enough money", "error", 5000, {
    title = "Store", align = "right", position = "bottom", playSound = true
})
```

Sticky (no timeout):

```lua
exports["cas-notification"]:addNotification({ message = "You are in admin mode", type = "info", title = "Admin", timeout = 0, sticky = true })
```

## Test command

With `enableTestCommand = true`, run `/Notifications` (rename via `Config.testCommand`) to preview a sequence of styled notifications.

## Troubleshooting

* **Nothing shows** — ensure the resource is started, `web/build/index.html` exists, and check the F8 console.
* **Wrong alignment** — check `Config.align` and that payloads don't override `align`/`position` unexpectedly.
* **No sound** — confirm client sound is on, `playSound` is not `false`, and `soundVolume` is not `0`.

## Support

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