M MY Multiplayer: Wiki
Side
Kind

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.

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

Parameters

NameTypeDescription
sendToplayer|table|elementA player, a table of players, or an element whose descendant players get the event. Left out, it goes to every player.default root
eventNamestringThe event's name on the clients.
bandwidthintBytes per second, from 1. Anything over 128 KB a second counts as 128 KB.default 5000
persistboolKeep sending after this resource stops. With false, the transfer is cancelled when the resource stops.default false
sourceelementThe element the event happens on, on the clients.
...anyArguments 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

addEventHandler("onPlayerJoin", root, function()
    local map = { name = "downtown", objects = {} }
    triggerLatentClientEvent(source, "onMapDownload", 50000, resourceRoot, map)
end)
NoteThe client only accepts the event if it registered it with addEvent(eventName, true).

See also