Yoda Things Documentation
  • πŸ’šYoda Things Documentation
  • INFORMATION
    • πŸ“ƒDiscord Roles
    • πŸ“€Assets Updates
    • βœ…Ensure/Start Order
  • PAID RESOURCES
    • πŸ—‘οΈAdvanced Garbage Job
      • 🧰Installation
      • βš™οΈConfiguration
    • 🚚PostOP Deliveries
      • 🧰Installation
      • βš™οΈConfiguration
    • πŸ“‹Reputation System
      • 🧰Installation
      • βš™οΈConfiguration
        • βœ…Add New Job's
        • πŸ“¬Exports
  • FREE RESOURCES
    • 🌐Notify System
    • πŸ’¨Oxy/Drug Runs
      • 🧰Installation
    • πŸ—‘οΈGarbage Job
      • 🧰Installation
    • πŸͺ¦Cemetery Robbery
      • 🧰Installation
      • βš™οΈConfiguration
Powered by GitBook
On this page
  • Introduction
  • Features
  • Installation and Configuration
  • Usage
  • Export notify
  • Test Command /notifytest
  • Required Parameters
  • Conclusion

Was this helpful?

  1. FREE RESOURCES

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.


Introduction

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.


Features

  • 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.


Installation and Configuration

  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.


Usage

Export notify

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

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)
})

Test Command /notifytest

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


Required Parameters

The script accepts the following parameters:

  • title Type: string Description: The title of the notification.

  • description Type: string Description: A detailed description for the notification.

  • type Type: string Allowed values: "success", "error", "info" Description: Determines the style and the default icon of the notification.

Note: 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 Type: number Description: The duration (in milliseconds) that the notification remains visible. Default is 5000.


Conclusion

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.

PreviousExportsNextOxy/Drug Runs

Last updated 3 months ago

Was this helpful?

🌐