triggerLatentServerEvent | Multi Theft Auto: Wiki Skip to content

triggerLatentServerEvent

Client-side
Server-side
Shared

Manual Review Required

Please finish this page using the corresponding Old Wiki article. Go to Contribution guidelines for more information.


This function is the same as triggerServerEvent 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.

Syntax

bool triggerLatentServerEvent ( string event, [ int bandwidth = 5000, bool persist = false ], element theElement, unknown arguments... )
Required Arguments
  • event: The name of the event to trigger server-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.
  • 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.
Optional Arguments

NOTE: When using optional arguments, you might need to supply all arguments before the one you wish to use.

  • bandwidth (default: 5000): The bytes per second rate to send the data contained in the arguments.
  • persist (default: false): A bool indicating whether the transmission should be allowed to continue even after the resource that triggered it has since stopped.

Returns

  • bool: value

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

Code Examples

shared
if fileExists("text.txt")
file = fileOpen("test.txt") --Open a file (you can create it yourself).
local data = fileRead(file,100*1024*1024) --Max 100 MB
fileClose(file) --Close File
triggerLatentServerEvent("onReadFile",5000,false,root,data) --trigger
end