Skip to main content

onScriptEvent

Register a listener function to be called when a script event is emitted.

Syntax

engine.network.onScriptEvent(event, listener);

Parameters

NameTypeDescription
eventstringThe event name to subscribe.
listener(data?: NetworkEventData) => voidThe listener.

Returns

  • listener - The listener.

Example

engine.network.onScriptEvent('onOpenDoor', (({status})) => {
if (status) {
door.open()
} else {
door.close()
}
});

Available on: Client Server