CAS-Notification

A lightweight, professional notification system for RedM using NUI and React.


🚀 Installation

  1. Download cas-notification resource into your resources folder:

  2. Ensure your server.cfg includes:

    ensure cas-notification
  3. Restart your server to load the resource.


🛠️ Configuration

No extra config file is required. By default, the following constants are used in client.lua:

  • Frame event: setVisible

  • Notification event: addNotification

  • Net event: cas-notification:client:addNotification

If you wish to customize event names, edit them in the top of client.lua.


🎨 Usage

Client-side

  • Open the NUI frame (for debugging or manual toggle):

    RegisterCommand('boiler', function()
        exports['cas-notification']:ToggleFrame(true)
    end)
  • Hide the NUI frame (from UI callback):

    RegisterNUICallback('hideFrame', function(_, cb)
        exports['cas-notification']:ToggleFrame(false)
        cb({})
    end)
  • Add a notification anywhere in client scripts:

    exports['cas-notification']:addNotification(
      message,    -- string, the text to display
      type,       -- string, one of "success", "error", "info"
      duration    -- integer, display time in milliseconds
    )
  • Listen for server triggers:

    RegisterNetEvent('cas-notification:client:addNotification')
    AddEventHandler('cas-notification:client:addNotification', function(msg, type, timeout)
      exports['cas-notification']:addNotification(msg, type, timeout)
    end)
  • Built-in test command:

    /Notifications

    Cycles through example success, error, and info notifications.


Server-side

Custom usage in any server script:

TriggerClientEvent(
  'cas-notification:client:addNotification',
  playerId,             -- target player server ID or -1 for all
  'Server message!',
  'error',
  8000
)

📚 API Reference

Function

Description

ToggleFrame(show: boolean)

Show or hide the NUI notification frame

addNotification(msg, type, timeout)

Queue a new notification to the client UI

RegisterNetEvent(CLIENT_EVENT)

Listen for server-triggered notifications


📝 Examples

Client:

-- Somewhere in your client script
exports['cas-notification']:addNotification(
  'Welcome to the server!',
  'success',
  7000
)

Server:

-- Anywhere on server side
TriggerClientEvent(
  'cas-notification:client:addNotification',
  targetPlayerId,
  'You have received a reward!',
  'info',
  5000
)

❤️ Contributing

Feel free to open ticket or contact us for get help.


© 2025 CAS Team

Last updated