Empresas
Empregos
  • Sobre nós
  • Soluções
    • Publicação de vagas
      Publique sua vaga e receba candidatos qualificados em 48h.
    • Avaliações de candidatos
      Mais de 500 testes técnicos e psicológicos, mais anti-fraude.
    • Headhunting
      Busca executiva personalizada do início ao fim.
    • Folha de Pagamento + EOR
      Dispersão de folha e EOR em mais de 15 países da LATAM.
  • Preços
  • Empregos

0

144
Visualizações
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 Respostas
Responde à pergunta

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 Relatório
Responde à pergunta
Encontrar trabalhos remotos

Descubra a nova forma de encontrar um emprego!

melhores empregos
Principais categorias de trabalho
Empresas
Postar vaga Preços Comercial
Jurídico
Termos e Condições Política de privacidade
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomende algumas ofertas para mim
Preciso de ajuda