addNetworkHandler

From GTA Connected
(Redirected from AddNetworkHandler)
Jump to navigation Jump to search

Function Server and Client All Games Online and Offline

Server 1.0.0, Client 1.0.0

void addNetworkHandler(string networkEventName, function handler)

Description

The addNetworkHandler function is used to add a handler for a custom network event that can be triggered via a server or client script.

Parameters

Type Name Presence Default Value Description
string networkEventName required n/a The name of the network event, case-insensitive.
function handler required n/a The scripting function to call when the network event occurs.

Returns

Success Returns

Type Description
void This function doesn't return any values on success.

Failure Returns

Type Value
void n/a

Callbacks

Server:
function(Client client, ...)
Client:

Notes

  • Use triggerNetworkEvent call a custom network event. Clients can only trigger server-side handlers, while the server can trigger a handler on either end.

Examples

Example 1 - JavaScript - Client-Side:

addNetworkHandler("walkToPos", function(civilian, x, y) {
    let walkToPos = new Vec2(x, y);
    civilian.walkTo(walkToPos);
});

Compatibility

There isn't any compatibility information for this function.

Related

Server Related

addNetworkHandler
removeNetworkHandler
triggerNetworkEvent


Client Related

addNetworkHandler
connect
disconnect
isConnected
isConnecting
removeNetworkHandler
triggerNetworkEvent