Empresas
Empleos
  • Sobre nosotros
  • Soluciones
    • Publicación de vacantes
      Publica tu vacante y recibe candidatos calificados en 48h.
    • Evaluación de candidatos
      500+ pruebas técnicas y psicológicas, más anti-fraude.
    • Headhunting
      Búsqueda ejecutiva a la medida de principio a fin.
    • Nómina + EOR
      Dispersión de nómina y EOR en más de 15 países de LATAM.
  • Precios
  • Empleos

0

138
Vistas
Add automatically a team?

I'm programming a game in which I have to set a team based on the position of the player when the game starts. Can you help me?

var playerz = [];

room.onPlayerJoin = function () {
  playerz.push({
    name: player.name,
    id: player.id,
    team: 0,
    position: { x: null, y: null },
  });

room.onGameStart = function () {
  TeamRed = playerz.filter(
    (p) => p.position["x"] === 103 && p.position["y"] === -178.5
  );
  TeamYellow = playerz.filter(
    (p) => p.position["x"] === -206 && p.position["y"] === 0
  );
  TeamBlue = playerz.filter(
    (p) => p.position["x"] === 103 && p.position["y"] === 178.5
  );
};

What I've done is to rename the player based on the position, but I actually need to rename the team based on these positions. Of course, I could do it manually verifying the position of each player but in some maps players are more than 10 so I need to do it automatically. Can someone help me?

P.S. Never mind about player, it's a built-in-game parameter.

about 4 years ago · Juan Pablo Isaza
1 Respuestas
Responde la pregunta

0

TeamRed.forEach(plr => playerz.find(o => o.id == plr.id).name = "Red");

I think this is what you're trying to accomplish?

about 4 years ago · Juan Pablo Isaza Denunciar
Responde la pregunta
Encuentra empleos remotos

¡Descubre la nueva forma de encontrar empleo!

Top de empleos
Top categorías de empleo
Empresas
Publicar vacante Precios Comercial
Legal
Términos y condiciones Política de privacidad
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomiéndame algunas ofertas
Necesito ayuda