Skip to main content

onServerEvent

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

Syntax

engine.network.onServerEvent(event, listener);

Parameters

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

Returns

  • listener - The listener.

Example

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

Available on: Client Server