Notifications
Simple, announcement and media notifications in MrPoulpi UI: client and server exports, fields, duration, pictures and placement above the minimap.
Three notification formats, callable from the client or the server. All of them have a progress bar showing the time left.
Simple notification
exports.mrpoulpi_ui:Notify('Vehicle stored in the garage', 'success')
exports.mrpoulpi_ui:Notify('You do not have enough money', 'error', 4000)
exports.mrpoulpi_ui:Notify(source, 'Payment received', 'success')
exports.mrpoulpi_ui:Notify(-1, 'Server restart in 5 minutes', 'warning', 10000)
| Argument | Description |
|---|---|
message |
Text, or a shared/locales.lua key. |
type |
success, info, warning or error. Otherwise Config.Notify.defaultType. |
duration |
In milliseconds. Otherwise Config.Notify.duration. Always kept between minDuration and maxDuration. |
Client side, Notify also accepts a table: { message = '…', type = 'info', duration = 3000, id = 'garage' }.
Announcement
A card with a logo, a name, a badge and a message. It is the format of company announcements.
exports.mrpoulpi_ui:Announce({
title = 'Real Estate Agent',
badge = 'Announcement',
message = 'New properties available in Vinewood!',
logo = 'https://cdn.example.com/agency.png',
type = 'success'
})
| Field | Description |
|---|---|
title |
Name in bold. |
badge |
Small label next to the name. |
message |
Announcement text. |
logo |
Optional picture (see Pictures). |
logoText |
Text of the logo square without a picture. LOGO by default. |
type |
Colour: success, info, warning or error. |
duration, id |
Same as Notify. |
Server side: exports.mrpoulpi_ui:Announce(source, data), with -1 for every player.
Media
A banner, a square picture and a caption: party poster, news flash, advert.
exports.mrpoulpi_ui:Media({
banner = 'News',
title = 'Party tonight at 11 pm',
image = 'https://cdn.example.com/poster.jpg',
duration = 10000
})
| Field | Description |
|---|---|
banner |
Banner text. News by default (ui_news key). |
title |
Caption under the picture. |
image |
Square picture (see Pictures). |
type, duration, id |
Same as Notify. |
Server side: exports.mrpoulpi_ui:Media(source, data).
Replacing or removing a notification
Each call returns an identifier (client side). Reusing an identifier replaces the notification on screen instead of adding one: handy for progress.
for i = 1, 5 do
exports.mrpoulpi_ui:Notify({ id = 'craft', message = ('Crafting %d/5'):format(i), type = 'info' })
Wait(1000)
end
exports.mrpoulpi_ui:RemoveNotification('craft')
ClearNotifications() removes everything.
Pictures
logo and image accept:
- an
https://…address; - a
nui://…address pointing to another resource; - an
assets/…path to a file placed in the resourcehtml/assets/folder.
Any other value is ignored and no picture is shown.
Placement and count
By default, notifications stack right above the minimap, aligned on its left edge and its width. The position is recomputed when the player opens the big map, hides the minimap or changes resolution or safe zone. Settings are in Config.Layout and Config.Minimap (configuration).
At most Config.Notify.max notifications are shown. A new one beyond that removes the oldest.
From another language or through events
The same notifications can be triggered with events, useful from a JavaScript or C# script:
TriggerClientEvent('mrpoulpi_ui:notify', source, 'Payment received', 'success', 5000)
TriggerClientEvent('mrpoulpi_ui:announce', -1, { title = 'LSPD', badge = 'Alert', message = 'Robbery in progress', type = 'error' })
The full list is in API and hooks.