Do you know what this error could be? Happens when I call this function in onPlayerJoin:
function startGame(victory, player) { // Serve para Mover os players para os times corretos
const players = room.getPlayerList()
if (victory) {
room.stopGame()
if (players.length >= 6) {
const playersSpec = room.getPlayerList().filter(p => p.team === 0)
const playersPlaying = room.getPlayerList().filter(p => p.team !== 0)
for (let i = 0; i < playersSpec.length; i++) {
if (playersPlaying.length === 0) {
if (i <= 9) {
const team = (i % 2) + 1
room.setPlayerTeam(playersSpec[i].id, team)
}
} else if (playersPlaying.length === 1) {
if (i <= 8) {
const team = (i % 2) + 1
room.setPlayerTeam(playersSpec[i].id, team)
}
}
}
room.startGame()
} else {
room.stopGame()
centralizedMessages(`❌ Players insuficientes para começar um novo jogo.`, undefined, colors.red, "bold", 2)
centralizedMessages(`🔄 Iniciando mapa de treinamento...`, undefined, colors.cu, "bold", 2)
setTrainningMap()
}
} else {
if (players.length >= 6 && gameStage.ranked === false) {
room.stopGame()
setAutoTeam('all')
centralizedMessages(`🔁 Batemos 6/10 players! Iniciado a partida...`, undefined, colors.green, "bold", 2)
room.setCustomStadium(map)
gameStage.ranked = true
setTimeout(() => room.startGame(), 2000)
}
else if (players.length < 6 && gameStage.ranked === false) {
if (!gameStage.playing) room.startGame()
gameStage.ranked = false
centralizedMessages(`😒 Estamos em fase de aquecimento... Aguarde mais ${6 - players.length} players para começar o jogo.`, undefined, colors.cu, "bold", 2)
room.setPlayerTeam(player.id, 1)
}
}
}