triggerNetworkEvent

Revision as of 13:39, 21 May 2022 by Vortrex (talk | contribs)
(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)

Function Server and Client icon-iii.png icon-vc.png icon-sa.png icon-iv.png Online Only

Available since Server 1.0.0, Client 1.0.0
Server:

void triggerNetworkEvent(string networkEventName, null or Client client, [ ... ])

Client:

void triggerNetworkEvent(string networkEventName, [ ... ])

The triggerNetworkEvent function is used to trigger a custom network event.

Parameters

1) string networkEventName The name of the network event, case-insensitive.
2) Client client Can be null. The client to trigger the network event for.
3) vararg ... Optional, defaults to n/a. Arguments to send to the scripting functions that are bound to the network event.

Return

void This function doesn't return a value.

Notes

  • When used in a server script, use null to send the event to all clients or specify a client object. See addNetworkHandler for information regarding custom event handler functions.

Examples

Example 1 - JavaScript - Server-Side:

function makeCivilianWalkToPos(civilian, x, y, z) {

   triggerNetworkEvent("walkToPos", null, civilian, x, y);

}

Compatibility

There isn't any compatibility information for this function.

Related

Server Related

        addNetworkHandler
        removeNetworkHandler


Client Related

        addNetworkHandler
        connect
        disconnect
  gta.shutdownAndLaunchNetworkGame
        isConnected
        isConnecting
        removeNetworkHandler