Skip to main content

GamePlayers

GamePlayer Manager

The GamePlayer Manager is a component of MooMoo.js that provides information about all players that are currently in the game.

Note, that this only includes players that either have been or are on the Leaderboard, players that have been rendered, or players that joined the game after you did.

The API tries as its best to keep track of all players that have been in the game, but it is not always possible to do so.

You can access the GamePlayer Manager and retrieve information about the players like this:

let gamePlayerManager = MooMoo.GamePlayerManager;

// Get all players
let players = gamePlayerManager.players;

// Get a player by their SID
let player = gamePlayerManager.getPlayerBySid(sid);

// Get a player by their ID
let player = gamePlayerManager.getPlayerById(id);

// Get a player by their name
let player = gamePlayerManager.getPlayerByName(name);

Same as for ActivePlayerManager, when using the getPlayerByName method, it will return an array of players if there are more than one player with the same name. Otherwise, it will return a single player object.

The players property will contain an array of player objects with the following structure:

{
players: [
{
"sid": 4,
"name": "unknown",
"id": "5TapKvA56N",
"x": 5951,
"y": 8207,
"dir": -2.65
}
]
}

Though, it may be possible that it looks like this:

{
players: [
{
"sid": 4,
"name": "unknown"
}
]
}

This is because the API could not view any other information that displayed on the leaderboard.