6,834
edits
No edit summary |
No edit summary |
||
Line 1: | Line 1: | ||
{{ | {{ScriptItem2 | ||
|name = addNetworkHandler | |||
|side = shared | |||
|type = function | |||
|games = iii vc sa iv | |||
|desc = add a handler for a custom network event that can be triggered via a server or client script. | |||
|arg1 = string networkEventName The name of the network event, case-insensitive. | |||
|arg2 = function handler The scripting function to call when the network event occurs. | |||
|return = void | |||
|freturn = void | |||
|note = Use [[triggerNetworkEvent|triggerNetworkEvent]] call a custom network event. Clients can only trigger server-side handlers, while the server can trigger a handler on either end. | |||
|offline = false | |offline = false | ||
| | |cb2arg1SS = Client client The client that triggered the network event. | ||
|cb2arg2SS = ... vararg The arguments that were triggered with the network event. | |||
|cb2arg1CS = ... vararg The arguments that were triggered with the network event. | |||
| | |||
| | |||
|exampleJSCS = addNetworkHandler("walkToPos", function(civilian, x, y) { | |exampleJSCS = addNetworkHandler("walkToPos", function(civilian, x, y) { | ||
let walkToPos = new Vec2(x, y); | let walkToPos = new Vec2(x, y); |
edits