Sending Notifications
From a client script
exports['gs-notify']:Notify('Garage', 'Your vehicle is ready.', 'success')
From a server script
The first value is who gets it:
exports['gs-notify']:Notify(source, 'Paycheck', 'You received $4,200.', 'money')
| Target | Who receives it |
|---|---|
source or a player id | That player |
{ 1, 2, 7 } | Those players |
'all' or nil | Everyone |
Ways to write a call
All of these work on the client and the server (server calls add the target first):
Notify('Title', 'Message', 'info', 5000) -- title + message + type + duration (ms)
Notify('Message', 'success') -- message + type
Notify('Message') -- message only
Notify({ type = 'success', title = 'Done', message = 'Saved.', duration = 4000 }) -- table, full control
With two strings, if the second one is a type name (success, error, ...), it's read as message + type. Otherwise it's title + message.
Options
Use these in the table style. Everything is optional.
| Option | What it does | Default |
|---|---|---|
type | Look and sound (see Types) | info |
title | Heading, up to 60 characters | the type name |
message | Body text, up to 300 characters. ~n~ makes a new line | empty |
duration | Milliseconds on screen (1200 to 60000). 0 = stays until closed | 5500 |
position | Where it appears (see Positions) | top-center |
persistent | true = stays until closed | false |
progress | Show the countdown bar | true |
priority | Stronger glow and entry animation | false |
icon | A type name like 'money', or a short emoji | by type |
image | A picture instead of an icon: https://, nui:// or a relative path | none |
accent | A custom colour, like '#ff8800' | by type |
sound | false = silent, or a type name to use that sound | by type |
volume | 0.0 to 1.0 | 0.5 |
id | Your own id, so you can update or close it later | auto |
metadata | Info pills (see below) | none |
actions | Buttons (see below) | none |
Other names also work: description, text or msg for message; length or time for duration; sticky for persistent; avatar for image.
Types
success · error · warning · info · message · dispatch · system · announcement · money · staff
Common names are mapped for you: primary/inform → info, warn/caution → warning, danger → error, police/ems → dispatch, bank/cash → money, admin → staff.
Positions
top-left · top-center · top-right · middle-left · middle-right · bottom-left · bottom-center · bottom-right
Info pills
metadata = {
{ label = 'Crew', value = '4/4' },
{ label = 'Payout', value = '$84,500' }
}
Up to 6 pills. A simple table like { Crew = '4/4', Payout = '$84,500' } also works.
Buttons
exports['gs-notify']:Notify({
type = 'dispatch',
title = '10-80 In Progress',
message = 'High speed chase',
actions = {
{ label = 'Set GPS', event = 'myjob:setGps' },
{ label = 'Report', event = 'myjob:server:report', server = true },
{ label = 'Dismiss' }
}
})
| Button option | What it does |
|---|---|
label | Button text |
event | Event to trigger on click (optional) |
server | true = trigger a server event |
args | Value passed to the event. If left out, the notification id is passed |
close | false = keep the notification open after the click |
Up to 3 buttons. Players press F10 to show the cursor, click, then press ESC to hide it. Buttons can only come from your own scripts, never from a player's request.
Update or close a notification
exports['gs-notify']:Notify({ id = 'download', title = 'Download', message = '40%', persistent = true })
exports['gs-notify']:Notify({ id = 'download', type = 'success', title = 'Download', message = 'Done!' }) -- replaces it
exports['gs-notify']:Close('download')
exports['gs-notify']:Clear() -- close everything
Notify returns the notification id, so you can save it and close it later.
Other client exports
exports['gs-notify']:SetPosition('bottom-right') -- change the default position
exports['gs-notify']:OpenSettings() -- open the player settings menu
Events
If you prefer events to exports:
-- server -> client
TriggerClientEvent('gs-notify:notify', source, 'Title', 'Message', 'success')
TriggerClientEvent('gs-notify:close', source, 'my-id')
TriggerClientEvent('gs-notify:clear', source)
-- client -> server (rate-limited; only admins can target other players)
TriggerServerEvent('gs-notify:server:notify', nil, 'Title', 'Message', 'info')