> For the complete documentation index, see [llms.txt](https://sbscripts.gitbook.io/sb-scripts/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://sbscripts.gitbook.io/sb-scripts/sb-notify/exports.md).

# Exports

Send SB Notify messages from client and server scripts.

### Client export

#### `exports['sbnotify']:Alert(caption, message, duration, type)`

Send a notification to the local player.

| Parameter  | Type     | Description                                                                 |
| ---------- | -------- | --------------------------------------------------------------------------- |
| `caption`  | `string` | Bold heading. Pass `''` to omit it.                                         |
| `message`  | `string` | Notification body.                                                          |
| `duration` | `number` | Display duration in milliseconds. Uses `Config.DefaultLength` when omitted. |
| `type`     | `string` | A key in `Config.Types`. Unknown values use `info`.                         |

```lua
exports['sbnotify']:Alert('Police', 'You are now wanted!', 7000, 'police')
exports['sbnotify']:Alert('', 'You received $500.', 5000, 'cash')
exports['sbnotify']:Alert('Mechanic', 'Vehicle repair complete.', 5000, 'mechanic')
```

### Server exports

#### `exports['sbnotify']:AlertPlayer(source, caption, message, duration, type)`

Send a notification to one player.

| Parameter  | Type     | Description                       |
| ---------- | -------- | --------------------------------- |
| `source`   | `number` | Player server ID.                 |
| `caption`  | `string` | Bold heading.                     |
| `message`  | `string` | Notification body.                |
| `duration` | `number` | Display duration in milliseconds. |
| `type`     | `string` | Notification type.                |

```lua
exports['sbnotify']:AlertPlayer(source, 'Cash', 'Paycheck received: $1,200', 6000, 'cash')
exports['sbnotify']:AlertPlayer(source, 'Error', 'You are not whitelisted.', 5000, 'error')
```

#### `exports['sbnotify']:AlertAll(caption, message, duration, type)`

Broadcast a notification to every connected player.

```lua
exports['sbnotify']:AlertAll('Server', 'Restart in 5 minutes.', 10000, 'warning')
exports['sbnotify']:AlertAll('Event', 'A new heist has started!', 8000, 'police')
```

### Client event

#### `'sbnotify:client:Alert'`

Use this event from the server when your workflow already uses `TriggerClientEvent`.

```lua
TriggerClientEvent('sbnotify:client:Alert', source, caption, message, duration, type)
```

| Parameter  | Type     | Description                                  |
| ---------- | -------- | -------------------------------------------- |
| `source`   | `number` | Player server ID. Use `-1` for every player. |
| `caption`  | `string` | Bold heading.                                |
| `message`  | `string` | Notification body.                           |
| `duration` | `number` | Display duration in milliseconds.            |
| `type`     | `string` | Notification type. `primary` maps to `info`. |

```lua
TriggerClientEvent('sbnotify:client:Alert', src, 'SB Storage', 'Item saved.', 5000, 'success')
TriggerClientEvent('sbnotify:client:Alert', -1, 'Server', 'Saving server data...', 5000, 'warning')
```

### QBCore integration

SB Notify overrides `QBCore.Functions.Notify` on the client.

Existing scripts work without changes. `primary` maps to `info`.

```lua
QBCore.Functions.Notify('Action completed!', 'success', 5000)
QBCore.Functions.Notify('Not enough money.', 'error', 5000)
QBCore.Functions.Notify('Welcome back.', 'primary', 5000)
QBCore.Functions.Notify('You died.')
```

### Notification stacking

Repeated `type` and `message` combinations do not create duplicates.

SB Notify increments a `×2`, `×3`, or higher badge. It also resets the timer.

```lua
exports['sbnotify']:Alert('', 'Not enough money.', 5000, 'error')
exports['sbnotify']:Alert('', 'Not enough money.', 5000, 'error')
exports['sbnotify']:Alert('', 'Not enough money.', 5000, 'error')
```
