> 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-chat/exports-and-events/client.md).

# Client

Client exports and events of Striga Chat.

## Exports

| Export                              | What it does                      |
| ----------------------------------- | --------------------------------- |
| `addMessage(message)`               | Adds a line to this player's chat |
| `addSuggestion(name, help, params)` | Adds help for a command           |

```lua
exports.chat:addMessage({ args = { 'System', 'Vehicle locked' } })

exports.chat:addSuggestion('/repair', 'Repair your vehicle', {
    { name = 'id', help = 'Vehicle id' },
})
```

## Events

| Event                   | Arguments             | What it does                  |
| ----------------------- | --------------------- | ----------------------------- |
| `chat:addMessage`       | `message`             | Adds a line                   |
| `chatMessage`           | `author, color, text` | Old style message             |
| `chat:addSuggestion`    | `name, help, params`  | Adds help for one command     |
| `chat:addSuggestions`   | `list`                | Adds help for many commands   |
| `chat:removeSuggestion` | `name`                | Removes the help of a command |
| `chat:addTemplate`      | `id, html`            | Adds an HTML template         |
| `chat:clear`            | -                     | Clears the chat               |
| `chat:addMode`          | `mode`                | Adds a mode                   |
| `chat:removeMode`       | `mode`                | Removes a mode                |

All of them can be sent from the server with `TriggerClientEvent(event, target, ...)` or on the client with `TriggerEvent`.

```lua
-- server
TriggerClientEvent('chat:addMessage', source, {
    color = { 56, 189, 248 },
    args = { 'Dispatch', 'Shots fired near Legion Square' },
})

TriggerClientEvent('chat:addSuggestion', -1, '/repair', 'Repair your vehicle')
TriggerClientEvent('chat:clear', source)
```

***

## For HUD and layout scripts

These exports are for scripts that want to move or color the chat, like a HUD editor.

| Export                   | What it does                                                                                                  |
| ------------------------ | ------------------------------------------------------------------------------------------------------------- |
| `SetPreview(true/false)` | Shows a still copy of the chat while your editor is open. Turned off by itself when your resource stops       |
| `SetLayout(settings)`    | Changes the player's chat settings (saved for that player). Returns `false` when `Config.Ui.Settings = false` |
| `GetFrame()`             | Returns the last chat box (`x`, `y`, `w`, `h` in screen %, plus settings)                                     |
| `SetTheme(color)`        | Sets the theme color, e.g. `'#3b82f6'`. `nil` removes it. Removed by itself when your resource stops          |

```lua
exports['striga-chat']:SetPreview(true)

exports['striga-chat']:SetLayout({
    x = 2, y = 60,          -- screen %, false = back to the config spot
    accent = '#22d3ee',     -- player color, false = follow the HUD / config again
    width = 110,            -- 70 to 160
    textScale = 100,        -- 80 to 140
    height = 100,           -- 50 to 200
    radius = 10,            -- 0 to 20
    opacity = 80,           -- 30 to 100
    blur = 8,               -- 0 to 16
    style = 'tinted',       -- card / tinted / compact
    timestamps = true,
    inputTag = false,
})

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

local frame = exports['striga-chat']:GetFrame()
```

### striga-chat:client:frame

Client event. Fires when the chat box changes, with the same table as `GetFrame()`.

```lua
AddEventHandler('striga-chat:client:frame', function(frame)
    print(frame.x, frame.y, frame.w, frame.h)
end)
```

{% hint style="info" %}
The theme color comes from the striga-core theme bus (`striga-core:client:theme`), and the `/hud` menu edits the chat settings through the striga-core settings hub. `SetTheme` stays for HUDs that call the chat directly. See [Settings Hub & Theme](/striga-docs/striga-core/settings-hub-and-theme.md).
{% endhint %}

{% content-ref url="/pages/yBebLpu33ZdycoXwtUDw" %}
[Server](/striga-docs/striga-chat/exports-and-events/server.md)
{% endcontent-ref %}
