Client exports

Client exports for notifications, text UI and alerts.

Notify

Shows a notification and returns its id.

lua
exports.mayo_notify:Notify('Vehicle stored', 'success')
exports.mayo_notify:Notify('Vehicle stored', 'success', 5000, 'Garage')
exports.mayo_notify:Notify({
    title = 'Garage',
    message = 'Vehicle stored',
    type = 'success',
    duration = 5000,
    icon = 'car',
    iconColor = '#BF5AF2',
    position = 'top-right',
    id = 'garage',
    persistent = false,
    sound = false,
})
FieldDefaultWhat it does
titleUp to 120 characters
messageUp to 1000 characters. description, text and msg also work
typeinfoA type from Types or an alias. style also works
durationConfig.DefaultDurationIn ms. 0 keeps it on screen until you remove it. length, time and timeout also work
iconThe type's iconA built-in icon or a Font Awesome name
iconColorThe type's colorAny hex color. color also works
positionConfig.PositionSee Positions
idGeneratedSending the same id again updates that card instead of adding a new one
persistentfalsetrue keeps it on screen until you remove it
soundThe type's sound{ 'name', 'soundSet' } for another sound, or false for none

A notification needs a title or a message. Other call styles work too, so scripts written for other notify resources can call it as they are:

lua
exports.mayo_notify:Notify('message', 'type', duration, 'title')        -- QBCore and ESX style
exports.mayo_notify:Notify({ description = 'message', type = 'error' })  -- ox_lib style
exports.mayo_notify:Notify('type', duration, 'message', 'title')        -- esx_notify style
exports.mayo_notify:Notify({ text = 'message', caption = 'title' }, 'type', duration)  -- QBCore text table

Remove

Removes a notification by id.

lua
local id = exports.mayo_notify:Notify({ message = 'Searching...', persistent = true })
exports.mayo_notify:Remove(id)

Clear

Removes every notification and alert on screen.

lua
exports.mayo_notify:Clear()

Text UI

lua
exports.mayo_notify:ShowTextUI('Open garage', { key = 'E', position = 'center-left' })
exports.mayo_notify:HideTextUI()
local open, text = exports.mayo_notify:IsTextUIOpen()
OptionDefaultWhat it does
keyThe key cap. Text like [E] - Open garage sets it for you
iconShown when there's no key. A built-in icon or a Font Awesome name
iconColorConfig.AccentColorAny hex color
positionConfig.TextUI.PositionSee Positions

The text can be up to 200 characters. Calling ShowTextUI again while it's open changes the text.

Dispatch

Shows a dispatch alert to this player only, and returns its id. It takes the same fields as the server export. To send an alert to a job, use the server export.

lua
exports.mayo_notify:Dispatch({ type = 'ems', title = 'Injured person', coords = GetEntityCoords(PlayerPedId()) })

Announce

Shows an announcement to this player only. Takes a message, or a table with title, message, author and duration.

lua
exports.mayo_notify:Announce('Welcome to the server!')