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

Get Player Count Per World

Discussion in 'Development' started by EmeraldMC, Dec 12, 2018.

  1. EmeraldMC

    EmeraldMC Creeper

    Messages:
    3
    GitHub:
    xxcauldevsyt
    I am trying to figure out how I would get a player count per world and make it display on a floating text or in a message can anyone help me it would really be appreciated.
     
  2. shabzz102

    shabzz102 Spider

    Messages:
    9
    GitHub:
    shabzz102
    PHP:
    $player->sendMessage("There are currently " count($level->getPlayers()) . " players in MyWorld");
     
    ZenixPlayzMC, A354-PH, Astro and 3 others like this.
  3. Astro

    Astro Slime

    Messages:
    78
    GitHub:
    RealAstro
    he's asking for a floating text, but it's the same just replace
    PHP:
    $player->sendMessage("There are currently " count($level->getPlayers()) . " players in MyWorld");
    with
    PHP:
    //must define $level
    $players count($level->getPlayers());
    $votecrate = new FloatingTextParticle(new Vector3(xyz), """Online Players: {$players}"); //also you must replace x, y, z with some actual coords...
     
    A354-PH likes this.
  4. Emirhan Akpınar

    Emirhan Akpınar Slime

    Messages:
    90
    PHP:
    /** @var Level $level */
    $count count($level->getPlayers());
    You can make this with function.

    PHP:
    /**
    * @var Level $level
    * @return int
    */

    public function getPlayerCount(Level $level): int {
      return 
    count($level->getPlayers());

    }
     
  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.