onPlayerEvent
Register a listener function to be called when a player event is emitted.
Syntax
engine.network.onPlayerEvent(event, listener);
Parameters
Name | Type | Description |
---|---|---|
event | string | The event name to subscribe. |
listener | (player: PlayerManager, data?: NetworkEventData) => void | The listener. |
Returns
listener
- The listener.
Example
engine.network.onPlayerEvent('onSayWelcome', player => {
engine.localPlayer.sendMessage(`${player.name} says: Welcome!`);
});
Available on: Client Server