TriggerLatentClientEvent

From Multi Theft Auto: Wiki
Revision as of 19:33, 12 January 2014 by Jaysds1 (talk | contribs)
Jump to navigation Jump to search
The printable version is no longer supported and may have rendering errors. Please update your browser bookmarks and please use the default browser print function instead.

This function is the same as triggerClientEvent except the transmission rate of the data contained in the arguments can be limited and other network traffic is not blocked while the data is being transferred.

[[{{{image}}}|link=|]] Note: You should avoid triggering events on the root element unless you really need to. Doing this triggers the event on every element in the element tree, which is potentially very CPU intensive. Use as specific (i.e. low down the tree) element as you can.

Syntax

bool triggerLatentClientEvent ( [table/element sendTo=getRootElement(),] string name, [int bandwidth=50000,] [bool persist=false,] element theElement, [arguments...] )

Required Arguments

  • name: The name of the event to trigger client side. You should register this event with addEvent and add at least one event handler using addEventHandler.
  • theElement: The element that is the source of the event. This could be another player, or if this isn't relevant, use the root element.

Optional Arguments

  • sendTo: The event will be sent to all players that are children of the specified element. By default this is the root element, and hence the event is sent to all players. If you specify a single player it will just be sent to that player. This argument can also be a table of player elements.
  • bandwidth: The bytes per second rate to send the data contained in the arguments.
  • persist: A bool indicating whether the transmission should be allowed to continue even after the resource that triggered it has since stopped.
  • arguments...: A list of arguments to trigger with the event. You can pass any lua data type (except functions). You can also pass elements. The total amount of data should not exceed 100MB.

Returns

Returns true if the event trigger has been sent, false if invalid arguments were specified.

Example

   --TODO

Requirements

Minimum server version 1.3.0-9.03772
Minimum client version n/a

Note: Using this feature requires the resource to have the above minimum version declared in the meta.xml <min_mta_version> section. e.g. <min_mta_version server="1.3.0-9.03772" />

Changelog

Version Description
1.3.0-9.04570 Added option to use a list of player elements for the 'sendTo' argument

See Also