Skip to content

Latest commit

 

History

History
164 lines (76 loc) · 2.32 KB

File metadata and controls

164 lines (76 loc) · 2.32 KB

Home > server > PlayerManager

PlayerManager class

Manages all connected players in a game server.

Signature:

export default class PlayerManager 

Remarks

The PlayerManager is created internally as a global singleton accessible with the static property PlayerManager.instance.

Events

This class emits global events with payloads listed under PlayerManagerEventPayloads

The constructor for this class is marked as internal. Third-party code should not call the constructor directly or create subclasses that extend the PlayerManager class.

Example

import { PlayerManager } from 'hytopia';

const playerManager = PlayerManager.instance;
const connectedPlayers = playerManager.getConnectedPlayers();

Properties

Property

Modifiers

Type

Description

instance

static

readonly

PlayerManager

The global PlayerManager instance as a singleton.

playerCount

readonly

number

The number of players currently connected to the server.

Methods

Method

Modifiers

Description

getConnectedPlayerByUsername(username)

Get a connected player by their username (case insensitive).

getConnectedPlayers()

Get all connected players.

getConnectedPlayersByWorld(world)

Get all connected players in a specific world.