Skip to content

Documentation

brianush1 edited this page Feb 16, 2019 · 2 revisions

Server

Event Ambassador.DataReceived(player: Player, name: string, data: any)

Fires whenever any data is received from the client side.


Ambassador:Send(name: string, player: Player, data: any)

Sends data to the client, retaining all of its functions and values. Note that values may be cached, so if the data is a reference (function, table, etc.), and its contents are updated but not the reference itself, it is important to clone it first before sending.


Ambassador:Await(name: string, player: Player, timeout: number = 30)

Receives data from the client, returning true, [data] on success, and false, [error] in the case of an error such as timing out.


Ambassador:Receive(name: string, player: Player, timeout: number = 30)

Receives data from the client, returning the resulting data in the case of success. In the case of an error, a Lua error is thrown. (Not recommended for use on the server)


Ambassador:Cleanup(player: Player)

Cleans up any Ambassador resources. If this function is not called, Ambassador will break upon the player's rejoining of the game.

Client

Event Ambassador.DataReceived(name: string, data: any)

Fires whenever any data is received from the server side.


Ambassador:Send(name: string, data: any)

Sends data to the server, retaining all of its functions and values. Note that values may be cached, so if the data is a reference (function, table, etc.), and its contents are updated but not the reference itself, it is important to clone it first before sending.


Ambassador:Await(name: string, timeout: number = 30)

Receives data from the server, returning true, [data] on success, and false, [error] in the case of an error such as timing out.


Ambassador:Receive(name: string, timeout: number = 30)

Receives data from the server, returning the resulting data in the case of success. In the case of an error, a Lua error is thrown. (Generally acceptable for use on the client, but use with caution)