> ## Documentation Index
> Fetch the complete documentation index at: https://fxscripts.dev/docs/llms.txt
> Use this file to discover all available pages before exploring further.

# Server exports

> Server-side exports for fxChat — send rich messages, broadcasts and system notifications.

These exports run on the server. Most of what you'll need lives here.

## `addMessage(target, options)`

Send a chat message to one player or everyone. The most-used export.

```lua Server theme={null}
exports.fxChat:addMessage(target, options)
```

<ParamField path="target" type="number | -1" required>
  Player server ID, or `-1` to broadcast to every connected player.
</ParamField>

<ParamField path="options.args" type="string" required>
  The message text. Supports inline color codes and a small markdown subset
  (see below).
</ParamField>

<ParamField path="options.title" type="string">
  Author label. Usually a character name or system name.
</ParamField>

<ParamField path="options.label" type="string">
  Colored pill-style tag rendered before the title. Common uses: `LSPD`,
  `EMS`, `ADMIN`.
</ParamField>

<ParamField path="options.labelSecondary" type="object">
  Optional second tag, useful for badge numbers.

  ```lua theme={null}
  labelSecondary = { text = '42', color = '#00ff00' }
  ```
</ParamField>

<ParamField path="options.color" type="string">
  Author color (`#hex`). Falls back to the active theme's accent.
</ParamField>

<ParamField path="options.badge" type="string">
  Built-in icon name, or any other string for plain text. Available icons:
  `person`, `cloud`, `chat`, `envelope`, `megaphone`, `shield`, `heart`,
  `globe`, `alert`, `radio`.
</ParamField>

<ParamField path="options.special" type="boolean" default="false">
  Adds a glow effect to highlight the message. Use sparingly.
</ParamField>

<ParamField path="options.tag" type="object">
  Override the visual tag entirely.

  ```lua theme={null}
  tag = { name = 'TAG', background = '#ff0000' }
  ```
</ParamField>

### Examples

```lua System message theme={null}
exports.fxChat:addMessage(source, {
    args = 'You picked up a wrench.',
    title = 'System',
})
```

```lua Police broadcast with badge theme={null}
exports.fxChat:addMessage(-1, {
    args = '10-91 in progress at Vespucci',
    title = 'Officer Smith',
    label = 'LSPD',
    labelSecondary = { text = '#247', color = '#9ca3af' },
    color = '#173ed9',
    badge = 'shield',
})
```

```lua Special / glowing theme={null}
exports.fxChat:addMessage(source, {
    args = '🏆 You won the round!',
    special = true,
    color = '#fbbf24',
})
```

### Inline color codes

Two formats inside `args`:

```lua theme={null}
-- SA:MP style ^N codes
args = 'Vehicle ^4stolen^0 at Vespucci'

-- HTML-style {#hex}text{/}
args = 'Vehicle {#FF5441}stolen{/} at Vespucci'
```

Both can be mixed in the same message. Available SA:MP codes are `^0`
(reset) and `^1` through `^9`.

### Markdown

```lua theme={null}
args = 'Type **bold**, __underline__, or use --- for a divider'
```

Markdown is parsed after HTML-escaping — XSS-safe.

***

## `clearChat(target?)`

Clear chat history for one player or everyone.

```lua Server theme={null}
exports.fxChat:clearChat(target)
```

<ParamField path="target" type="number | -1 | nil">
  Player server ID. Pass `-1` or omit to clear chat for all players.
</ParamField>

```lua Examples theme={null}
-- Clear for one player
exports.fxChat:clearChat(source)

-- Clear for everyone
exports.fxChat:clearChat(-1)
```

***

## `setMuted(target, muted, durationMs?)`

Mute a player so their messages are silently dropped server-side.

```lua Server theme={null}
exports.fxChat:setMuted(target, muted, durationMs)
```

<ParamField path="target" type="number" required>
  Player server ID to mute / unmute.
</ParamField>

<ParamField path="muted" type="boolean" required>
  `true` to mute, `false` to unmute.
</ParamField>

<ParamField path="durationMs" type="number">
  Optional auto-unmute delay in milliseconds. Omit for indefinite mute.
</ParamField>

```lua Examples theme={null}
-- 5-minute mute
exports.fxChat:setMuted(source, true, 5 * 60 * 1000)

-- Permanent mute
exports.fxChat:setMuted(source, true)

-- Unmute
exports.fxChat:setMuted(source, false)
```

***

## `isMuted(target)`

Check whether a player is currently muted.

```lua Server theme={null}
local muted = exports.fxChat:isMuted(target)
```

<ParamField path="target" type="number" required>
  Player server ID.
</ParamField>

<ParamField path="returns" type="boolean">
  `true` if currently muted.
</ParamField>

***

<Note>
  Missing an export you need? [Ask in Discord](https://discord.gg/HCcpPmNrHH) —
  we ship new ones when there's a real use case.
</Note>
