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

# Events

Default chat events, message checks and chat visibility.

#### Default chat events

Every event of the default FiveM chat works, so scripts written for it need no edits.

| Event                   | Description                                                                                                                                                                            |
| ----------------------- | -------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| `chat:addMessage`       | Shows a message. Takes the same fields as the [addMessage export](https://grp-development.gitbook.io/solid-scripts/resources/solid-chat/exports-and-events/server-exports#addmessage). |
| `chat:addSuggestion`    | Adds a command suggestion.                                                                                                                                                             |
| `chat:addSuggestions`   | Adds several suggestions at once.                                                                                                                                                      |
| `chat:removeSuggestion` | Removes a suggestion.                                                                                                                                                                  |
| `chat:addTemplate`      | Adds a message template.                                                                                                                                                               |
| `chat:clear`            | Clears the chat. `chat:clearChat` works too.                                                                                                                                           |
| `chat:addMode`          | Adds a chat mode.                                                                                                                                                                      |
| `chat:removeMode`       | Removes a chat mode.                                                                                                                                                                   |
| `chatMessage`           | Old style message with an author, a colour and text. RGB colour tables work.                                                                                                           |

These are client events. Send them from the server with `TriggerClientEvent`:

```lua
TriggerClientEvent('chat:addMessage', source, {
    args = { 'Bank', 'You received $500.' },
})
```

#### Stop a public message

Every public chat message fires `chatMessage` on the server before it is delivered. Cancel the event to stop the message.

```lua
AddEventHandler('chatMessage', function(source, author, text)
    if text:find('discord.gg', 1, true) then
        CancelEvent()
    end
end)
```

To change a message or send it to other players, use a [message hook](https://grp-development.gitbook.io/solid-scripts/resources/solid-chat/exports-and-events/server-exports#registermessagehook).

#### Chat visibility

HUD scripts can hide or dim themselves while the chat is on screen. `chat:visibilityChanged` fires on the client when the chat shows or hides:

```lua
AddEventHandler('chat:visibilityChanged', function(visible)
    DisplayRadar(not visible)
end)
```

The same value is in the player's `chatVisible` state bag:

```lua
local visible = LocalPlayer.state.chatVisible
```


---

# Agent Instructions
This documentation is published with GitBook. GitBook is the documentation platform designed so that both humans and AI agents can read, navigate, and reason over technical content effectively. Learn more at gitbook.com.

## Querying This Documentation
If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter, and the optional `goal` query parameter:

```
GET https://grp-development.gitbook.io/solid-scripts/resources/solid-chat/exports-and-events/events.md?ask=<question>&goal=<endgoal>
```

`ask` is the immediate question: it should be specific, self-contained, and written in natural language.
`goal` is optional and describes the broader end goal you are ultimately trying to accomplish on behalf of the user. GitBook uses it to tailor the answer towards what is most useful for that goal.

The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
