> For the complete documentation index, see [llms.txt](https://yoda-things.gitbook.io/yoda-things-documentation/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://yoda-things.gitbook.io/yoda-things-documentation/free-resources/notify-system.md).

# Notify System

This documentation explains how the notifications script works for FiveM. The script sends messages from Lua to the NUI (using SendReactMessage) and displays custom notifications in the UI. In this version, only the required parameters are implemented: **title**, **description**, and **type**. An optional **duration** parameter is also available.

***

## <mark style="background-color:blue;">Introduction</mark>

The NUI Notifications Script was developed for FiveM to facilitate communication between the client-side (Lua) and the user interface (NUI). It sends notifications via the `SendReactMessage` function. This script requires three parameters—**title**, **description**, and **type**—to display a notification. If any required field is missing, an error message is printed in the console.

***

## <mark style="background-color:blue;">Features</mark>

* **Notification Delivery:**\
  Sends custom notifications to the UI with the action `triggerNotification`.
* **Simple Validation:**\
  Checks for the required parameters (`title`, `description`, and `type`). If any are missing, an error is logged.
* **Test Command:**\
  A `/notifytest` command is provided to send sample notifications for testing purposes.

***

## <mark style="background-color:blue;">Installation and Configuration</mark>

1. **FiveM Environment:**\
   Ensure your FiveM server is properly configured and that the resource containing this script is included in your `server.cfg`.
2. **Script Integration:**\
   Place the script in a FiveM resource and start it along with your other resources.

***

## <mark style="background-color:blue;">Usage</mark>

### <mark style="background-color:purple;">Export notify</mark>

The script exports a function `notify` so other resources can send notifications to the UI. For example:

```lua
exports['yoda-notify']:notify({
  title = "Notification title",         -- Required
  description = "Notification description", -- Required
  type = "success",                      -- Required ("success", "error", or "info")
  duration = 6000                        -- Optional (default: 5000 ms)
})
```

### <mark style="background-color:purple;">Test Command /notifytest</mark>

To test the notification system, use the `/notifytest` command. This command sends three notifications to the UI, demonstrating the three basic types:

* Success Notification
* Error Notification
* Info Notification

***

## <mark style="background-color:blue;">Required Parameters</mark>

The script accepts the following parameters:

* **title**\
  \&#xNAN;*Type:* `string`\
  \&#xNAN;*Description:* The title of the notification.
* **description**\
  \&#xNAN;*Type:* `string`\
  \&#xNAN;*Description:* A detailed description for the notification.
* **type**\
  \&#xNAN;*Type:* `string`\
  \&#xNAN;*Allowed values:* `"success"`, `"error"`, `"info"`\
  \&#xNAN;*Description:* Determines the style and the default icon of the notification.

> <mark style="color:red;">**Note:**</mark> If any of these required fields are not provided, the script will print an error in the console indicating which field(s) are missing.

An optional parameter is also available:

* **duration**\
  \&#xNAN;*Type:* `number`\
  \&#xNAN;*Description:* The duration (in milliseconds) that the notification remains visible. Default is `5000`.

***

## <mark style="background-color:blue;">Conclusion</mark>

This script provides a simple and effective way to send notifications to the NUI in FiveM, relying on just the essential parameters: **title**, **description**, and **type** (with an optional **duration**). It ensures that notifications are displayed correctly and that any missing required fields are reported via console errors.


---

# Agent Instructions
This documentation is published with GitBook. GitBook is the documentation platform designed so that both humans and AI agents can read, navigate, and reason over technical content effectively. Learn more at gitbook.com.

## Querying This Documentation
If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://yoda-things.gitbook.io/yoda-things-documentation/free-resources/notify-system.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
