1. The forums will be archived and moved to a read only mode in about 2 weeks (mid march).

To get 4 players into random teams?

Discussion in 'Plugin Help' started by WEATHERCRAFTYT1, Nov 18, 2020.

  1. WEATHERCRAFTYT1

    WEATHERCRAFTYT1 Baby Zombie

    Messages:
    121
    Hello, I want to get 4 random players from here and send them a message like “You got the secret message”. Anyway to do this here.
    PHP:
    public function startGame() {
            
    $players = [];
            foreach (
    $this->players as $player) {
                
    $players[$player->getName()] = $player;
                
    $player->setGamemode($player::SURVIVAL);
            }


            
    $this->players $players;
     
  2. mmm545

    mmm545 Baby Zombie

    Messages:
    152
    GitHub:
    mmm545
    PHP:
    $players array_rand($this->getServer()->getOnlinePlayers(), 4); //number of players (or elements) to randomly pick from the array
     
  3. WEATHERCRAFTYT1

    WEATHERCRAFTYT1 Baby Zombie

    Messages:
    121
  1. This site uses cookies to help personalise content, tailor your experience and to keep you logged in if you register.
    By continuing to use this site, you are consenting to our use of cookies.