Closed bartosz-lanik closed 6 years ago
You can filter them using filter()
function
Feel free making your own functions using existing ones.
As an example you can make function that is called resetPlayers()
which loops on all of the players and use setPlayerTeam()
to set their teams into 0 (Spectator teamId).
function GetRedTeam(){return room.getPlayerList().filter((player) => player.team == 1);}; function GetBlueTeam(){return room.getPlayerList().filter((player) => player.team == 2);}; function GetSpecTeam(){return room.getPlayerList().filter((player) => player.team == 0);};
or function GetTeam(id){return room.getPlayerList().filter((player) => player.team == id);};
To Move Everyone To Spec: function MoveAllToSpec() { var allPlayers = room.getPlayerList().filter((player) => player.id!= 0); for(var i = 0; i < allPlayers.length; i++) { room.setPlayerTeam(allPlayers[i].id, 0); } room.sendChat("Done!"); }
I wont be adding these methods since they are easily doable from the already existing api.
Hello. Function getPlayerList() should have an option to choose a team to select from. Function setPlayerTeam() should have an option to move all players from team to spec. Greetings, Manderigon.