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

How can we change a server's player count?

Discussion in 'Development' started by BruhLol, Feb 25, 2018.

  1. BruhLol

    BruhLol Baby Zombie

    Messages:
    122
    Can we change a server's(hub) player count in server list motd to a count of players on all other branch servers
     
  2. MalakasPlayzMCPE

    MalakasPlayzMCPE Zombie Pigman

    Messages:
    667
    Max players:
    PHP:
    $this->getModifier()->setMaxPlayerCount(number);
    Players inside the server:
    PHP:
    $this->getModifier()->setPlayers(number);
     
  3. BruhLol

    BruhLol Baby Zombie

    Messages:
    122
    what? where's the getModifier() defined?
     
    Muqsit likes this.
  4. Muqsit

    Muqsit Chicken

    Messages:
    1,548
    GitHub:
    muqsit
    You can use QueryRegenerateEvent to change the displayed player count and max player count.
    PHP:
    /** @var QueryRegenerateEvent $event */
    $event->setPlayerCount(currentPlayerCount);
    $event->setMaxPlayerCount(maxPlayerCount);
     
    BruhLol likes this.
  5. BruhLol

    BruhLol Baby Zombie

    Messages:
    122
    Yes, ty, but should i query other server's player count each tick?
     
  6. BruhLol

    BruhLol Baby Zombie

    Messages:
    122
    nvm gotcha!
     
  7. Muqsit

    Muqsit Chicken

    Messages:
    1,548
    GitHub:
    muqsit
    QueryRegenerateEvent is called every 10 seconds or so. So you can have a repeating task yhat repeats every 10 seconds (200 ticks) which queries the other servers.
     
    falk, BruhLol and xXNiceAssassinlo YT like 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.