onServerEvent
Register a listener function to be called when a server event is emitted.
Syntax
engine.network.onServerEvent(event, listener);
Parameters
Name | Type | Description |
---|---|---|
event | string | The event name to subscribe. |
listener | (data?: NetworkEventData) => void | The listener. |
Returns
listener
- The listener.
Example
engine.network.onServerEvent('onOpenDoor', (({status})) => {
if (status) {
door.open()
} else {
door.close()
}
});
Available on: Client Server