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

# Exports & Events

Show notifications from your own scripts.

{% hint style="success" %}
**Quick start**

Client: `exports['striga-notify']:Notify('Vehicle locked', 'success')`\
Server: `exports['striga-notify']:Notify(source, 'Not enough money', 'error')`
{% endhint %}

## Notification options

You can send plain text, or a table with these fields:

| Field         | Type   | Default    | What it does                                                                                                                                             |
| ------------- | ------ | ---------- | -------------------------------------------------------------------------------------------------------------------------------------------------------- |
| `description` | string | -          | The message                                                                                                                                              |
| `title`       | string | -          | Heading above the message (optional)                                                                                                                     |
| `type`        | string | `'info'`   | `info`, `success`, `warning`, `error`                                                                                                                    |
| `duration`    | number | `5000`     | Time on screen in ms, 1000 to 30000                                                                                                                      |
| `id`          | string | -          | Same `id` updates this notification instead of adding a new one                                                                                          |
| `icon`        | string | type icon  | Icon name, see the list below                                                                                                                            |
| `iconColor`   | string | type color | `#rrggbb` or `#rgb` (an alpha part is ignored), or `red` `green` `blue` `yellow` `orange` `purple` `pink` `cyan` `white` `gray`. Replaces the type color |
| `sound`       | bool   | `true`     | `false` = no sound for this notification                                                                                                                 |

You need at least a `description` or a `title`.

{% hint style="info" %}
`inform`, `primary` (= info) and `warn` (= warning) also work, so ox\_lib and QBCore types need no change.
{% endhint %}

### Icons

Font Awesome style names work:

`check` `xmark` `car` `phone` `money-bill` `bank` `house` `key` `lock` `user` `bell` `gas-pump` `truck` `box` `heart` `shield` `clock` ...

An unknown name shows the icon of the type.

### Text

Text is always shown as plain text. HTML tags and color codes (`~r~`, `^1`) are removed, `<br>` and `~n~` keep the line break.

***

## Client exports

### Notify

Shows a notification. Returns `true` if it was shown.

{% tabs %}
{% tab title="Text" %}

```lua
-- Notify(text, type?, duration?, icon?)
exports['striga-notify']:Notify('Vehicle locked', 'success', 5000)
exports['striga-notify']:Notify('Engine damaged', 'warning', 5000, 'car')
```

{% endtab %}

{% tab title="Table" %}

```lua
exports['striga-notify']:Notify({
    title = 'Bank',
    description = '$500 received',
    type = 'success',
    duration = 5000,
    icon = 'money-bill',
})
```

{% endtab %}

{% tab title="Update with id" %}

```lua
-- First call shows it, the next calls with the same id change it
exports['striga-notify']:Notify({ id = 'repair', description = 'Repairing 30%', type = 'info' })
exports['striga-notify']:Notify({ id = 'repair', description = 'Repairing 80%', type = 'info' })
exports['striga-notify']:Notify({ id = 'repair', description = 'Repair done', type = 'success' })
```

{% endtab %}
{% endtabs %}

### Hide

Removes one notification by its `id`.

```lua
exports['striga-notify']:Hide('repair')
```

### Clear

Removes all notifications.

```lua
exports['striga-notify']:Clear()
```

***

## Server exports

### Notify

Shows a notification to one player, or to everyone with `-1`. Returns `true` if it was sent.

```lua
-- Notify(playerId, text, type?, duration?)
exports['striga-notify']:Notify(source, 'Not enough money', 'error', 5000)

-- Notify(playerId, table)
exports['striga-notify']:Notify(source, {
    title = 'Bank',
    description = '$500 received',
    type = 'success',
})

-- Everyone
exports['striga-notify']:Notify(-1, 'Server restart in 5 minutes', 'warning', 10000)
```

{% hint style="warning" %}
Max **20 notifications per second** to the same player. More are dropped, so a loop can not flood a player.
{% endhint %}

***

## Through striga-core (recommended)

If your script already uses **striga-core**, use `Core.notify` (see [striga-core exports](/striga-docs/striga-core/exports.md)). It works with whatever notify script the server owner picks, not only Striga Notify.

```lua
-- client
Core.notify('Vehicle locked', 'success', 5000)
Core.notify({ title = 'Bank', description = '$500 received', type = 'success' })

-- server
Core.notify(source, 'Not enough money', 'error', 5000)
Core.notify(source, { title = 'Bank', description = '$500 received', type = 'success' })
```

***

## Framework functions

After the [Integration](/striga-docs/striga-notify/integration.md) step, the normal notify functions of ESX, QBCore, Qbox and ox\_lib also show in the Striga Notify design. No change in your scripts needed.

***

## Events

### striga-notify:client:show

Client event. Shows a notification on that player. Takes the same table as `Notify`.

```lua
-- server
TriggerClientEvent('striga-notify:client:show', source, {
    description = 'Package delivered',
    type = 'success',
})

-- client
TriggerEvent('striga-notify:client:show', { description = 'Package delivered', type = 'success' })
```

{% hint style="info" %}
On the server, prefer the `Notify` export: it checks the data and has the 20 per second limit.
{% endhint %}

***

## For HUD and layout scripts

These exports are for scripts that want to control the look, like a HUD menu.

{% hint style="info" %}
Striga Tokyo HUD does not need them anymore. It sends its theme through striga-core (`striga-core:client:theme`), and its `/hud` menu edits the Notify settings through the striga-core settings hub. These exports stay for older HUDs and your own scripts.
{% endhint %}

| Export                   | What it does                                                                                                                                               |
| ------------------------ | ---------------------------------------------------------------------------------------------------------------------------------------------------------- |
| `SetTheme(color)`        | Sets the color of the settings panel, e.g. `'#3b82f6'`. `nil` removes it. Removed by itself when your resource stops. Notifications keep their type colors |
| `SetLayout(settings)`    | Changes the player's settings (saved on their PC)                                                                                                          |
| `SetPreview(true/false)` | Keeps sample notifications on screen while your editor is open                                                                                             |
| `GetSettings()`          | Returns the player's current settings                                                                                                                      |

```lua
exports['striga-notify']:SetTheme('#3b82f6')

exports['striga-notify']:SetLayout({
    style = 'tinted',       -- card / tinted / compact
    iconStyle = 'bar',      -- plain / tile / bar
    position = 'top-left',
    opacity = 80,           -- 30 to 100
    size = 110,             -- 80 to 140
    blur = 8,               -- 0 to 16
    progress = true,
    sound = false,
})

exports['striga-notify']:SetLayout({ reset = true }) -- back to config defaults

local settings = exports['striga-notify']:GetSettings()
print(settings.style, settings.position)
```

{% content-ref url="/pages/r57BAHdrw11lLdGFfbiH" %}
[Troubleshooting & FAQ](/striga-docs/striga-notify/troubleshooting-and-faq.md)
{% endcontent-ref %}
