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

Get players in certain level

Discussion in 'Development' started by WreckagePE / ZAYD, Mar 26, 2017.

  1. WreckagePE / ZAYD

    WreckagePE / ZAYD Slime

    Messages:
    82
    I see servers that have floating text like 'kitpvp {player_count} playing'
    These are getting how many players are in a world and replacing with {player_count}.
    If i was to do this with slapper, how so? And, how do i get amount of players on the level?
     
  2. Sandertv

    Sandertv Zombie Pigman Poggit Reviewer

    Messages:
    786
    GitHub:
    Sandertv
    To get the amount of players in a level, use count($level->getPlayers());
     
    HimbeersaftLP likes this.
  3. WreckagePE / ZAYD

    WreckagePE / ZAYD Slime

    Messages:
    82
    Yeah, but;
    If i edited the slapper plugin
    $kitpvpplayers = $this->getLevel(KitPvP)
    Then I made it so {KITPVP_PLAYERS} replaces $kitpvpplayers, would it work?
     
  4. Jack Noordhuis

    Jack Noordhuis Zombie Pigman Poggit Reviewer

    Messages:
    618
    GitHub:
    JackNoordhuis
    Yea, if you did it properly. You might wanna update the count every x ticks to make sure a somewhat accurate count is displayed tho.
    PHP:
    str_replace("{KITPVP_PLAYERS"count(Server::getLevelByName("KitPvP")->getPlayers()), $name);
     
  5. Muqsit

    Muqsit Chicken

    Messages:
    1,548
    GitHub:
    muqsit
    It's a not very noob friendly thing to do. If you understand everything about repeating tasks and somewhat of entity classes, I can help you.
     
  6. WreckagePE / ZAYD

    WreckagePE / ZAYD Slime

    Messages:
    82
    @Muqsit i know nothin about repeatin tasks to be honest :oops:
     
  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.