triggerNetworkEvent: Difference between revisions

From GTA Connected
Jump to navigation Jump to search
No edit summary
 
No edit summary
 
(One intermediate revision by one other user not shown)
Line 1: Line 1:
{{ScriptItem
{{ScriptItem
|offline = false
|endpoint = shared
|endpoint = shared
|type = function
|type = function
Line 13: Line 14:
|return1 = void
|return1 = void
|returnFail1 = void
|returnFail1 = void
|notes = When used in a server script, use null to send the event to all clients or specify a client object. See [[Shared/Functions/Network/addNetworkHandler|addNetworkHandler]] for information regarding custom event handler functions.<br>
|notes = When used in a server script, use null to send the event to all clients or specify a client object. See [[Shared/Functions/Network/addNetworkHandler|addNetworkHandler]] for information regarding custom event handler functions.
|exampleJSSS = function makeCivilianWalkToPos(civilian, x, y, z) {
|exampleJSSS = function makeCivilianWalkToPos(civilian, x, y, z) {
     triggerNetworkEvent("walkToPos", null, civilian, x, y);
     triggerNetworkEvent("walkToPos", null, civilian, x, y);
}
}
}}
}}

Latest revision as of 13:39, 21 May 2022

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

icon-iii.png icon-vc.png icon-sa.png icon-iv.png addNetworkHandler
icon-iii.png icon-vc.png icon-sa.png icon-iv.png removeNetworkHandler


Client Related

icon-iii.png icon-vc.png icon-sa.png icon-iv.png addNetworkHandler
icon-iii.png icon-vc.png icon-sa.png icon-iv.png connect
icon-iii.png icon-vc.png icon-sa.png icon-iv.png disconnect
icon-iv.png gta.shutdownAndLaunchNetworkGame
icon-iii.png icon-vc.png icon-sa.png icon-iv.png isConnected
icon-iii.png icon-vc.png icon-sa.png icon-iv.png isConnecting
icon-iii.png icon-vc.png icon-sa.png icon-iv.png removeNetworkHandler