A unified system for managing multiple notification resources.
Each supported resource is organized into a table of handlers, with a trigger function and type mapping.
This approach enables easy integration and switching between resources.
Developers can simply extend the handlers table to add support for additional resources if required.
Handlers
Table of handlers for notification resources.
Covered by default: boii_ui, ox_lib, qb-core, es_extended, okokNotify
Client
local handlers = {boii_ui=function(options)TriggerEvent('boii_ui:notify', { type = options.type, header = options.header, message = options.message, duration = options.duration })end,ox_lib=function(options)TriggerEvent('ox_lib:notify', { type = options.type, title = options.header, description = options.message })end,es_extended=function(options)TriggerEvent('ESX:Notify', options.type, options.duration, options.message)end, ['qb-core'] =function(options)local type_mapping = { information ='primary', info ='primary' } options.type = type_mapping[options.type] or options.typeTriggerEvent('QBCore:Notify', options.message, options.type, options.duration)end,okokNotify=function(options)TriggerEvent('okokNotify:Alert', options.header or'Notification', options.message, options.type, options.duration or5000)end--- Add other resources here}
Server
Server side notifications require a source player
local handlers = {boii_ui=function(_src,options)TriggerEvent('boii_ui:notify', _src, { type = options.type, header = options.header, message = options.message, duration = options.duration })end,ox_lib=function(_src,options)TriggerEvent('ox_lib:notify', _src, { type = options.type, title = options.header, description = options.message })end,es_extended=function(_src,options)TriggerEvent('ESX:Notify', _src, options.type, options.duration, options.message)end, ['qb-core'] =function(_src,options)local type_mapping = { information ='primary', info ='primary' } options.type = type_mapping[options.type] or options.typeTriggerEvent('QBCore:Notify', _src, options.message, options.type, options.duration)end,okokNotify=function(_src,options)TriggerEvent('okokNotify:Alert', _src, options.header or'Notification', options.message, options.type, options.duration or5000)end}
Client Functions
notify
Sends a notification to client player.
Function
localfunctionnotify(options)ifnot options ornot options.type ornot options.message thenprint('Invalid notification data provided.')returnendlocal handler = handlers[NOTIFICATIONS] or handlers['boii_ui']handler(options)endexports('notify', notify)utils.ui.notify = notify
Example
--- Utils objectutils.ui.notify({ header ='Test Notification', message ='Just another test notification..', type ='info', duration =3500})--- Direct exportexports.boii_utils:notify(...)
Server Functions
notify
The same as client side, except here we pass the players source.
Function
localfunctionnotify(_src,options)ifnot options ornot options.type ornot options.message thenprint('Invalid notification data provided.')returnendlocal handler = handlers[NOTIFICATIONS] or handlers['boii_ui']handler(_src, options)endexports('notify', notify)utils.ui.notify = notify
Example
--- Utils objectutils.ui.notify(_src, { header ='Test Notification', message ='Just another test notification..', type ='info', duration =3500})--- Direct exportexports.boii_utils:notify(...)
Guides
Initial Setup
Currently the utils library requires the UI resources be defined within the config.
This may be moved to resource detection in future however for now it has not been needed.
To set your chosen UI resources head to server/config.lua
Find the following section and pick your choices.
--- UI Bridge settings--- @field drawtext: Specifies the active progressbar system. Options: 'boii_ui', 'qb-core', 'es_extended', 'ox_lib', 'okokTextUI', 'custom'.--- @field notify: Specifies the active notification system. Options: 'boii_ui', 'qb-core', 'es_extended', 'ox_lib', 'okokNotify', 'custom'.--- @field progressbar: Specifies the active progressbar system. Options: 'boii_ui', 'custom'.config.ui = { drawtext ='boii_ui', notify ='boii_ui', progressbar ='boii_ui'}
If your desired resource is not already covered by default follow the instructions below on how to add a new handler.
Adding Handlers
To add support for addition resources you need to add a handler into the handlers table inside .../bridges/notifications.lua