Notifications

Types, positions, stacking, formatting and history.

Types

Mayo Notify comes with success, error, info, warning, police, ems and fire. Each has its own color, icon and sound, and you can add more in Types. Type names from other scripts, like primary, inform or danger, are mapped with Type aliases.

A notification can also have its own icon and icon color. See Client exports.

Positions

Notifications show in Config.Position, top-right by default. A single notification can go somewhere else with position:

top-left, top-center, top-right, center-left, center-right, bottom-left, bottom-center and bottom-right

top, bottom, left and right also work, as top-center, bottom-center, center-left and center-right.

Each position shows up to Config.MaxVisible notifications. When a new one comes in, the oldest is dropped.

Stacking

With Config.Stack = true, a notification that matches one already on screen (same type, title, message, icon and position) doesn't add a new card. The existing card shows a count, and its timer starts over. Handy for scripts that send the same message many times in a row.

Duration

Notifications stay for Config.DefaultDuration ms unless the script sends its own duration. A duration of 0 or persistent = true keeps a notification on screen until the script removes it.

Formatting

Titles and messages support:

  • **bold**
  • Line breaks, as a new line or ~n~
  • GTA color codes: ~r~, ~g~, ~b~, ~y~, ~o~, ~p~, ~c~, ~m~, ~w~, ~u~ and ~h~. ~s~ goes back to the normal color.
lua
exports.mayo_notify:Notify('You paid ~g~$500~s~ for **Fuel**', 'success')

HTML is never shown, so anything a player types shows as plain text.

History

/notifications opens the history panel. It keeps the last Config.History.Max notifications, dispatch alerts and announcements, with the time each one came in. The same notification twice in a row shows once, with a count.

Clear empties the history. Esc or the close button closes it.

Set Config.History.Enabled = false to turn it off.