Skip to main content

ActivePlayers

ActivePlayers Manager

The ActivePlayers Manager is a component of MooMoo.js that provides information about the players currently being rendered in the game. This includes details such as their session ID (sid), name, position, and other relevant information.

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

let activePlayerManager = MooMoo.ActivePlayerManager;
let players = activePlayerManager.players;

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
}
]
}

Note that the player objects contain much more information than what is shown here. To learn more about the available data and methods in the Player object, you can check out the Player page.

The Manager also provides you functions to search for certain players.

If you want to search for a player by SID, you can do that like this:

let player = MooMoo.ActivePlayerManager.getPlayerBySid(sid)

You can also get a player by its ID:

let player = MooMoo.ActivePlayerManager.getPlayerById(id)

You can also get a player / players by their name:

let player = MooMoo.ActivePlayerManager.getPlayerByName(name)

If there are more than one player with the same name, this method will return an array of players. Otherwise, it will return a single player object.

getting other data

The ActivePlayers Manager also provides you with a way to get information about the enemies and / or all players around you.

Here are all the methods that are available:

let activePlayerManager = MooMoo.ActivePlayerManager;

let enemies = activePlayerManager.getEnemies();
// returns an array of enemies

let teammates = activePlayerManager.getTeammates();
// returns an array of teammates

let nearestEnemy = activePlayerManager.getClosestEnemy();
// returns the nearest enemy

let nearestTeammate = activePlayerManager.getClosestTeammate();
// returns the nearest teammate

let nearestPlayer = activePlayerManager.getClosestPlayer();
// returns the nearest player

let nearestplayertoplayer = activePlayerManager.getClosestEnemyToPlayer(player);
// this function takes in a player object and returns the nearest enemy to that player

let nearestEnemyAngle = activePlayerManager.getClosestEnemyAngle();
// returns the angle to the nearest enemy

let nearestEnemyDistance = activePlayerManager.getClosestEnemyDistance();
// returns the distance to the nearest enemy