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

how to get the level a player is in and the amount of players

Discussion in 'Development' started by rektpixel, Feb 17, 2018.

  1. rektpixel

    rektpixel Baby Zombie

    Messages:
    186
    Hello pmmp!
    I'm wanting to get the world a player is in and then get the number of players in that world. I have this, but it seems to be the incorrect method :/ could someone help me :)
    PHP:
                       $gamecounter $player->getLevel->getLevelByName()->getPlayers();
                       
    $playersArena count($gamecounter);
     
  2. Kyd

    Kyd Zombie Pigman

    Messages:
    678
    GitHub:
    boi1216
    PHP:
    count($player->getLevel()->getPlayers());
     
    rektpixel likes this.
  3. kenygamer

    kenygamer Banned Banned

    Messages:
    106
    GitHub:
    kenygamer
    PHP:
    $world Player->getLevel()->getFolderName(); //string
    $worldPlayerCount count(Player->getLevel()->getPlayers()); //int
     
    Last edited: Feb 19, 2018
    OnTheVerge likes this.
  4. SOFe

    SOFe Administrator Staff Member PMMP Team Poggit Admin

    Messages:
    1,968
    GitHub:
    sof3
    getName() returns the name in level.dat, and getFolderName() returns the folder name. Usually we use getFolderName() for identifying the level, e.g. in Server->getLevelByName().
     
    kenygamer likes this.
  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.