Skip to main content

emitToPlayer

Emit an event to a specific player on the server.

Syntax

engine.network.emitToPlayer(player, event, data);

Parameters

NameTypeDescription
playerPlayerManager or numberThe player manger or player ID.
eventstringThe event name to emit.
data (optional)NetworkEventDataThe event data.

Example

// with player manager
engine.network.emitToPlayer(player, 'onOpenDoor', {
doorId: 1,
status: true,
});

// with player id
engine.network.emitToPlayer(1, 'onOpenDoor', {
doorId: 1,
status: true,
});

Available on: Client Server