Skip to main content

BenzyNotifications — Integrations

How to route another resource's notifications through BenzyNotifications. If a resource sends its messages through a single notify funnel with a style switch, adding BenzyNotifications is a one-line change; if it doesn't, you can call the export wherever you'd show a notification.

Contents


The contract

BenzyNotifications exposes the same Notify signature on both sides:

  • Client: exports.BenzyNotifications:Notify(kind, title, message, duration) — shows a toast on the calling client.
  • Server: exports.BenzyNotifications:Notify(source, kind, title, message, duration) — pushes a toast to player source.

kind is 'success' | 'error' | 'info' | 'warning' | 'request'; duration is optional (falls back to Config.Duration). That is the whole contract — see EXPORTS.md.


Routing a resource's notifications through it

Many resources send every message through one notify function with a config switch that picks the style. To send those toasts here, add a 'BenzyNotifications' branch to that function and select it in the config:

-- In the other resource's client notify funnel (e.g. client/cl_notify.lua)
function Notify(kind, title, message, duration)
kind = kind or 'info'

if Config.Notify == 'BenzyNotifications' and GetResourceState('BenzyNotifications') == 'started' then
exports.BenzyNotifications:Notify(kind, title, message, duration)

-- ... the resource's existing 'chat' / 'native' / 'custom' branches ...
end
end
-- In that resource's config.lua
Config.Notify = 'BenzyNotifications'

The arguments pass straight through, so the branch is all you add.


Using it from any resource (no funnel)

You don't need a funnel to use BenzyNotifications — just call the export where you would have shown a notification:

-- Client
exports.BenzyNotifications:Notify('success', 'Craft', 'You crafted a lockpick.')
-- Server (to a specific player)
exports.BenzyNotifications:Notify(source, 'error', 'Craft', 'You are missing materials.')

Prefer a per-kind shorthand (Success, Error, Info, Warning, Request) if you'd rather not pass a kind, and pass either positional args or an options table — see EXPORTS.md for every export and both call styles:

-- Client, shorthand
exports.BenzyNotifications:Success('Craft', 'You crafted a lockpick.')
-- Client, options table (ox_lib-style fields work too)
exports.BenzyNotifications:Notify({ type = 'error', title = 'Craft', description = 'You are missing materials.' })

Guard the call with GetResourceState('BenzyNotifications') == 'started' if the notifier is optional, and fall back to chat/native so your resource still works without it. See the worked example in EXPORTS.md.


Making it your own

Everything visual is in config.lua:

  • Config.Duration — how long toasts stay (ms).
  • Config.Position — one of eight screen anchors.
  • Config.MaxVisible — how many stack at once.
  • Config.Kinds — the accent color + icon for each style. Add a new key here and any caller that passes that kind gets your custom style; unknown kinds fall back to info.

For deeper visual changes the toast markup + styles live in html/ — it's a small, self-contained layer with no dependencies.