Advertisement
  1. This site uses cookies. By continuing to use this site, you are agreeing to our use of cookies. Learn More.

get player in the world

Comments in 'Plugin Development' started by GamesLoad, May 20, 2015.

  1. GamesLoad
    Offline

    GamesLoad Active Member

    Joined:
    Jun 28, 2014
    Posts:
    106
    Minecraft User:
    GamesLoad
    Hello I wanted to know how do I know how many players there are in a world with a variable thanks!
  2. CraftYourBukkit
    Offline

    CraftYourBukkit Notable Member Plugin Developer

    Joined:
    Jan 20, 2015
    Posts:
    1,022
    Plugins:
    2
    Minecraft User:
    CraftYourBukkit
    I think it's
    PHP:
    $this->getServer()->getLevel("name")->getPlayers();
  3. GamesLoad
    Offline

    GamesLoad Active Member

    Joined:
    Jun 28, 2014
    Posts:
    106
    Minecraft User:
    GamesLoad
    I need to import something?
  4. CraftYourBukkit
    Offline

    CraftYourBukkit Notable Member Plugin Developer

    Joined:
    Jan 20, 2015
    Posts:
    1,022
    Plugins:
    2
    Minecraft User:
    CraftYourBukkit
    No
  5. iksaku
    Offline

    iksaku Notable Member Plugin Developer

    Joined:
    Sep 2, 2013
    Posts:
    1,130
    Plugins:
    4
    Minecraft User:
    iksaku
    Wrong, it should be "getLevelByName()"
    Or if you already have the "Level Object" do:
    PHP:
    $level->getOnlinePlayers();
    This returns a "Player array" type, you can use "count" to count the number of entries, and a "foreach" loop to access each player object
    CraftYourBukkit likes this.
  6. PEMapModder
    Offline

    PEMapModder Notable Member Plugin Developer

    Joined:
    Oct 9, 2013
    Posts:
    7,294
    Plugins:
    11
    Minecraft User:
    PEMapModder
    PHP:
    public Player[] pocketmine\Server::getOnlinePlayers(): exists;
    public 
    Player[] pocketmine\level\Level::getPlayers(): exists;
    public * 
    pocketmine\level\Level::getOnlinePlayers(): doesn't exist;
  7. iksaku
    Offline

    iksaku Notable Member Plugin Developer

    Joined:
    Sep 2, 2013
    Posts:
    1,130
    Plugins:
    4
    Minecraft User:
    iksaku
    Oops xD

Share This Page

Advertisement