triggerNetworkEvent: Difference between revisions
Jump to navigation
Jump to search
No edit summary |
No edit summary |
||
Line 1: | Line 1: | ||
{{ScriptItem | {{ScriptItem | ||
|offline = false | |||
|endpoint = shared | |endpoint = shared | ||
|type = function | |type = function |
Latest revision as of 13:39, 21 May 2022
Function
Server and Client
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