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

How can I clear all of player

Discussion in 'Development' started by Hoyee, Mar 16, 2020.

  1. Hoyee

    Hoyee Baby Zombie

    Messages:
    126
    Code:
     $this->getServer()->getOnlinePlayers()->getInventory()->clearAll();
             $this->getServer()->getOnlinePlayers()->kill();
             $this->getServer()->getOnlinePlaeyrs()->setGamemode(0);
    not working. It says "Call to a member function getInventory() on array"
     
  2. GamakCZ

    GamakCZ Zombie Pigman

    Messages:
    598
    GitHub:
    GamakCZ
    HimbeersaftLP likes this.
  3. iBa4x

    iBa4x Spider Jockey

    Messages:
    32
    GitHub:
    iBa4x
    " $this->getServer()->getOnlinePlayers() " works as in array so you can't do some thing with it..
    you need to get player by player not all player at once!

    so use foreach like this:
    PHP:
    $players $this->getServer()->getOnlinePlayers();

    foreach(
    $players as $player){
         
    //here you can use it for player by player with $player.
    }
     
  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.