Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

135
Views
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 answers
Answer question

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 Report
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!