# triggerLatentClientEvent (Server)

> Sends an event to the players' clients bit by bit, in the background, at no more than `bandwidth` bytes a second per player. Meant for large data that must not hold up the rest of the traffic.

- **Platform**: MY Multiplayer (MYMP)
- **Kind**: Lua Function
- **Side**: Server
- **Category**: Events
- **URL**: https://wiki.mymp.gg/en/triggerLatentClientEvent

## Syntax

```lua
bool triggerLatentClientEvent(string eventName, element source, any ... [, player|table|element sendTo = root, int bandwidth = 5000, bool persist = false])
```

## Parameters

| Name | Type | Description |
| --- | --- | --- |
| `sendTo` | `player\|table\|element` | A player, a table of players, or an element whose descendant players get the event. Left out, it goes to every player. *(default: `root`)* |
| `eventName` | `string` | The event's name on the clients. |
| `bandwidth` | `int` | Bytes per second, from 1. Anything over 128 KB a second counts as 128 KB. *(default: `5000`)* |
| `persist` | `bool` | Keep sending after this resource stops. With `false`, the transfer is cancelled when the resource stops. *(default: `false`)* |
| `source` | `element` | The element the event happens on, on the clients. |
| `...` | `any` | Arguments passed to the handlers on the other side: `nil`, booleans, numbers, strings, elements, vectors and tables of them. |

## Returns

`true` if the event was queued, `false` if it is over 16 MB or a million values.

Each player gets a copy of their own, with its own handle. Latent events to the same destination go out one at a time, in the order they were triggered. `getLatentEventHandles` gives each one's handle, to follow with `getLatentEventStatus` or stop with `cancelLatentEvent`.

## Example

```lua
addEventHandler("onPlayerJoin", root, function()
    local map = { name = "downtown", objects = {} }
    triggerLatentClientEvent(source, "onMapDownload", 50000, resourceRoot, map)
end)
```

### Note

The client only accepts the event if it registered it with `addEvent(eventName, true)`.

## See also

- [triggerClientEvent (Server)](https://wiki.mymp.gg/en/triggerClientEvent.md): Sends an event to the players' clients, which trigger it on source. The function returns before the clients receive it.
- [getLatentEventHandles (Server)](https://wiki.mymp.gg/en/getLatentEventHandles-server.md): Lists the latent events the server is still sending to a player.
- [getLatentEventStatus (Server)](https://wiki.mymp.gg/en/getLatentEventStatus-server.md): Tells how a latent event the server is sending to a player is going.
- [cancelLatentEvent (Server)](https://wiki.mymp.gg/en/cancelLatentEvent-server.md): Stops a latent event the server is sending to a player. The client drops what it had received and the event is not triggered there.
