how can i create a function that chooses 2 objects from an array and picks each one back and forth? *(example) for use with minigame, send one player to team red and then send the next player to team blue, and the next player back to team red... etc* object 1 in my array holds the cords position for red team spawnpoint object 2 holds the blue team spawn point Code: --- world: blueSpawn: - 10.629100 - 55.000000 - 55.617400 redSpawn: - 10.445700 - 55.000000 - 9.381400 ...
You need a constant count of teams. PHP: $teams = 3; Everytime a player joins or quits the minigame you have to increase or decrease the number of players. PHP: $players = $players + 1; After that you can calculate it using modulo: PHP: $playerTeam = $players % $teams;switch ($playerTeam) { case 0: echo "Team 1"; break; case 1: echo "Team 2"; break; case 2: echo "Team 3"; break;}