BenzyNotifications — Events
Events you can trigger (a convenient alternative to the exports) and events you can listen to, each with a ready-to-paste example. The exports are usually cleaner, but events are handy for resources that already speak in TriggerEvent.
kind, title, message, and duration mean the same as in EXPORTS.md — see that file for the notification kinds (colors + icons) and the accepted field names.
Events you can trigger
BenzyNotifications:Notify (client, net event)
The channel the server pushes a toast on — trigger it from the server to show a toast on a player. The payload is a table (the same field names the options-table export form accepts).
-- Server -> a single player
TriggerClientEvent('BenzyNotifications:Notify', source, {
kind = 'success', title = 'Garage', message = 'Your car has been stored.'
})
-- Server -> everyone
TriggerClientEvent('BenzyNotifications:Notify', -1, {
kind = 'info', title = 'Server', message = 'A restart is scheduled in 5 minutes.', duration = 10000
})
BenzyNotifications:Show (client, local)
Show a toast on this client from another client-side script. Takes positional args (or an options table as the first arg).
-- Client (local toast)
TriggerEvent('BenzyNotifications:Show', 'error', 'Locked', 'This door is locked.')
BenzyNotifications:Clear (client)
Dismiss every toast on a player's screen. Trigger it from the server (targeted or -1) or locally on the client.
TriggerClientEvent('BenzyNotifications:Clear', source) -- clear one player's toasts
TriggerClientEvent('BenzyNotifications:Clear', -1) -- clear everyone's
BenzyNotifications:Send (server → server)
A convenience wrapper around the Notify export, for resources that prefer events. Not a net event, so a client cannot reach it.
TriggerEvent('BenzyNotifications:Send', source, 'success', 'Paycheck', 'The city paid you $1,500.')
BenzyNotifications:Broadcast (server → server)
A convenience wrapper around the NotifyAll export.
TriggerEvent('BenzyNotifications:Broadcast', 'info', 'Event', 'The bank heist has started downtown!')
Events BenzyNotifications fires (listen with AddEventHandler)
BenzyNotifications:Ready (server)
Fired once when the resource has started. Handy if another resource wants to wait for it before wiring itself up.
AddEventHandler('BenzyNotifications:Ready', function()
print('BenzyNotifications is ready')
end)
If you want to know whether a push reached a player, prefer the exports in EXPORTS.md — the server
Notifyreturnstruefor a valid server id (andfalseotherwise). Events do not return a value.