addNetworkHandler
Jump to navigation
Jump to search
Function
Server and Client
Online and Offline
Available since Server 1.0.0, Client 1.0.0
void addNetworkHandler(string networkEventName, function handler)
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
1) | string | networkEventName | The name of the network event, case-insensitive. |
2) | function | handler | The scripting function to call when the network event occurs. |
Return
void | This function doesn't return a value. |
Callbacks
Server-Side Callbacks
function handler(Client client, ...)
1) | Client | client | The client that triggered the network event. |
2) | ... | vararg | The arguments that were triggered with the network event. |
Client-Side Callbacks
function handler(...)
1) | ... | vararg | The arguments that were triggered with the network event. |
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
Client Related
addNetworkHandler
connect
disconnect
gta.shutdownAndLaunchNetworkGame
isConnected
isConnecting
removeNetworkHandler