> For the complete documentation index, see [llms.txt](https://mango-5m.gitbook.io/mango5m-docs/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://mango-5m.gitbook.io/mango5m-docs/free-resources/mango-notify/developer-guide/server-exports.md).

# Server Exports

Send notifications from server scripts — to one player or everyone.

Server exports mirror the client API with one difference: **the first argument is always the target player id**. Pass `-1` to send to everyone online.

{% hint style="warning" %}
**A `nil` player id is rejected, not broadcast.** Because `-1` means *everyone*, an accidental `nil` (easy to hit when `source` is read from the wrong context) would otherwise notify your whole server. Mango Notify refuses it and logs a warning instead.

The same applies to a non-numeric id, and to a player who has since disconnected — the notification is dropped and the console tells you which export it came from.
{% endhint %}

Every server export returns `true` when the notification went out and `false` when it did not, so you can branch on it:

```lua
if not exports.mango_notify:Success(source, 'Paycheck', 'Salary paid.') then
    -- player disconnected mid-transaction, or source was nil
end
```

Use `NotifyAll(data)` when you actually mean everyone.

```lua
exports.mango_notify:Notify(playerId, data)
exports.mango_notify:Success(playerId, title, description, duration)
exports.mango_notify:Error(playerId, title, description, duration)
exports.mango_notify:Warning(playerId, title, description, duration)
exports.mango_notify:Info(playerId, title, description, duration)
exports.mango_notify:Dispatch(playerId, data)

exports.mango_notify:Money(playerId, amount, extra)          -- sign decides the wording
exports.mango_notify:MoneyReceived(playerId, amount, extra)
exports.mango_notify:MoneyRemoved(playerId, amount, extra)

exports.mango_notify:Update(playerId, id, data)
exports.mango_notify:Remove(playerId, id)
exports.mango_notify:Clear(playerId)

exports.mango_notify:NotifyAll(data)     -- shorthand for Notify(-1, data)
```

## Interactive prompts

`promptServer` shows a prompt on that player's screen and calls your **server-side** callback with the answer — the calling resource does not need its own client file or a reply event.

```lua
exports.mango_notify:promptServer(playerId, data, function(result)
    -- result = the chosen action's value, or nil
end)
```

Unlike every other server export, `-1` is **not** accepted here — a prompt is a question with one answer, so it needs one target. It returns a token string when the prompt went out, and `false` when it did not.

The answer is validated against the actions you sent, so a modified client cannot feed arbitrary values into your callback. If the player disconnects or never answers, your callback still fires with `nil` once the window closes. Full guide: [Interactive Prompts](/mango5m-docs/free-resources/mango-notify/developer-guide/interactive-prompts.md).

## Examples

```lua
-- pay day
RegisterCommand('payday', function(source)
    exports.mango_notify:MoneyReceived(source, 1250)
end)

-- Money() reads the sign, so a single call handles both directions
exports.mango_notify:Money(source,  1250)   -- "You received: 1250$"
exports.mango_notify:Money(source, -1250)   -- "You paid: 1250$"

-- server-wide announcement, persistent until cleared
exports.mango_notify:NotifyAll({
    id          = 'restart_warning',
    type        = 'warning',
    title       = 'Server restart',
    description = 'Restarting in 5 minutes — find a safe spot.',
    duration    = 0,
})

-- later:
exports.mango_notify:Update(-1, 'restart_warning', { description = 'Restarting in 1 minute!' })
exports.mango_notify:Remove(-1, 'restart_warning')
```

{% hint style="info" %}
Prefer events? The same operations are available as server-side events — see [Events](/mango5m-docs/free-resources/mango-notify/developer-guide/events.md).
{% endhint %}
