# sendDuiMessage (Client)

> Sends a message to a dui's page. The page receives it in the `window`'s `message` event.

- **Platform**: MY Multiplayer (MYMP)
- **Kind**: Lua Function
- **Side**: Client
- **Category**: Web interface
- **URL**: https://wiki.mymp.gg/en/sendDuiMessage

## Syntax

```lua
bool sendDuiMessage(dui dui, table|string message)
```

## Parameters

| Name | Type | Description |
| --- | --- | --- |
| `dui` | `dui` | The dui. |
| `message` | `table\|string` | A table, sent as JSON, or a string already in JSON. |

## Returns

`true` if the message was sent. `false` with a wrong argument (logs a warning).

A message sent before the page has loaded waits and is delivered once it loads.

## Example

```lua
local dui = createDui("https://example.com/scoreboard.html", 512, 512)
sendDuiMessage(dui, { type = "score", team = "grove", points = 12 })
```

### Note

A string reaches the page exactly as written, so it must be valid JSON.

## See also

- [createDui (Client)](https://wiki.mymp.gg/en/createDui.md): Opens a web page off screen, with a transparent background, and gives it back as an image that can be drawn.
- [isDuiReady (Client)](https://wiki.mymp.gg/en/isDuiReady.md): Tells whether a dui's page has finished loading.
- [sendNuiMessage (Client)](https://wiki.mymp.gg/en/sendNuiMessage.md): Sends a message to the interface page of the calling resource. The page receives it in the window's message event.
