---
description: >-
  Notification System Setup This section outlines the setup of a notification
  system using a custom event and a command in a FiveM server. The notification
  system allows for different types of alerts to
---

# NOTIFICATION

```
RegisterNetEvent('es:showNotification', function(message, title, type, length, icon)
    AddNotify(message, title, type, length, icon)
end)
```

**Parameters:**

* `message`: The content of the notification, which will be shown to the player.
* `title`: The title of the notification, typically summarizing the type of alert.
* `type`: The notification type, which determines the visual style (e.g., "info", "error", "warning", "announce", "purple").
* `length`: The duration (in milliseconds) for which the notification will be displayed.
* `icon`: The icon associated with the notification, either as an image file or a Font Awesome icon class.

**Usage**

You can trigger this event from anywhere within the server code using:

```
TriggerEvent('es:showNotification', "This is your message", "Notification Title", "info", 5000, "fas fa-info-circle")
```

This will display a notification with the specified message, title, type, and icon for 5 seconds.

**2. Command Registration: `notify`**

A command named `notify` is registered, which triggers a series of notifications with predefined messages. This is useful for testing or broadcasting specific notifications to the player.

**Command Definition**

```
RegisterCommand("notify", function(source, args)
    AddNotify("Your phone has received a new message. Check it for important details and updates.", "PHONE NOTIFICATION", "info", 5000, "phone.png")
    Wait(1000)
    AddNotify("An error occurred. Please review the details to avoid potential issues.", "ERROR NOTIFICATION", "error", 5000, "fas fa-info-circle")
    Wait(1000)
    AddNotify("Caution! A potential issue has been detected. Immediate attention is required.", "WARNING NOTIFICATION", "warning", 5000, "fas fa-info-circle")
    Wait(1000)
    AddNotify("Important announcement for all players. Please read the following information carefully.", "ANNOUNCEMENT NOTIFICATION", "announce", 5000, "announce.png")
    Wait(1000)
    AddNotify("A special chat message has been sent to you containing unique information.", "CHAT NOTIFICATION", "purple", 5000, "chat.png")
    AddNotify("Your phone has received a new message. Check it for important details and updates.", "PHONE NOTIFICATION", "info", 5000, "phone.png")
    Wait(1000)
    AddNotify("An error occurred. Please review the details to avoid potential issues.", "ERROR NOTIFICATION", "error", 5000, "fas fa-info-circle")
    Wait(1000)
    AddNotify("Caution! A potential issue has been detected. Immediate attention is required.", "WARNING NOTIFICATION", "warning", 5000, "fas fa-info-circle")
    Wait(1000)
    AddNotify("Important announcement for all players. Please read the following information carefully.", "ANNOUNCEMENT NOTIFICATION", "announce", 5000, "announce.png")
    Wait(1000)
    AddNotify("A special chat message has been sent to you containing unique information.", "CHAT NOTIFICATION", "purple", 5000, "chat.png")
end, false)
```

* **Usage:**
  * Players can trigger this command by typing `/notify` in the chat.
  * The command will sequentially display several predefined notifications with 1-second intervals between them.

**Example Notifications**

1. **Phone Notification:**\
   &#xNAN;_&#x4D;essage:_ "Your phone has received a new message. Check it for important details and updates."\
   &#xNAN;_&#x54;itle:_ "PHONE NOTIFICATION"\
   &#xNAN;_&#x54;ype:_ "info"\
   &#xNAN;_&#x49;con:_ "phone.png"
2. **Error Notification:**\
   &#xNAN;_&#x4D;essage:_ "An error occurred. Please review the details to avoid potential issues."\
   &#xNAN;_&#x54;itle:_ "ERROR NOTIFICATION"\
   &#xNAN;_&#x54;ype:_ "error"\
   &#xNAN;_&#x49;con:_ "fas fa-info-circle"
3. **Warning Notification:**\
   &#xNAN;_&#x4D;essage:_ "Caution! A potential issue has been detected. Immediate attention is required."\
   &#xNAN;_&#x54;itle:_ "WARNING NOTIFICATION"\
   &#xNAN;_&#x54;ype:_ "warning"\
   &#xNAN;_&#x49;con:_ "fas fa-info-circle"
4. **Announcement Notification:**\
   &#xNAN;_&#x4D;essage:_ "Important announcement for all players. Please read the following information carefully."\
   &#xNAN;_&#x54;itle:_ "ANNOUNCEMENT NOTIFICATION"\
   &#xNAN;_&#x54;ype:_ "announce"\
   &#xNAN;_&#x49;con:_ "announce.png"
5. **Chat Notification:**\
   &#xNAN;_&#x4D;essage:_ "A special chat message has been sent to you containing unique information."\
   &#xNAN;_&#x54;itle:_ "CHAT NOTIFICATION"\
   &#xNAN;_&#x54;ype:_ "purple"\
   &#xNAN;_&#x49;con:_ "chat.png"
6.  **Conclusion**

    This setup provides a flexible way to trigger and manage notifications within the FiveM server, using either custom events or a simple command. The notifications can be easily customized to fit various scenarios, improving communication with players.
