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

Set the player count

Comments in 'Plugin Development' started by CrazedMiner, Aug 18, 2015.

  1. CrazedMiner
    Offline

    CrazedMiner Notable Member Plugin Developer

    Joined:
    Jan 31, 2015
    Posts:
    348
    Plugins:
    2
    Minecraft User:
    CrazedMinerYT
    I was wondering how you would set the player count and if it is possible to set it to anything I want (Something other than the online players / max players). I've read other threads talking about this and was wondering if anyone could provide some examples of how to do it. Thanks!
  2. jojoe77777
    Offline

    jojoe77777 Notable Member Plugin Developer

    Joined:
    May 28, 2015
    Posts:
    653
    Plugins:
    1
    Minecraft User:
    jojoe77777
    QueryRegenerateEvent (I think)
  3. CrazedMiner
    Offline

    CrazedMiner Notable Member Plugin Developer

    Joined:
    Jan 31, 2015
    Posts:
    348
    Plugins:
    2
    Minecraft User:
    CrazedMinerYT
    I'll test this, wouldn't you have to create a query in order for the event to trigger or does it get called by PM on startup?
  4. jojoe77777
    Offline

    jojoe77777 Notable Member Plugin Developer

    Joined:
    May 28, 2015
    Posts:
    653
    Plugins:
    1
    Minecraft User:
    jojoe77777
    I'm just guessing, but PocketMine probably triggers a QueryRegenerateEvent every few seconds or when someone pings....? So when that happens, before it gets sent to the client, edit the event to change player count.
    CrazedMiner likes this.
  5. jojoe77777
    Offline

    jojoe77777 Notable Member Plugin Developer

    Joined:
    May 28, 2015
    Posts:
    653
    Plugins:
    1
    Minecraft User:
    jojoe77777
    Just checked docs, here's some example code:

    PHP:
    public function queryRegen(QueryRegenerateEvent $ev){
    $ev->setPlayerCount(50);
    }
    That will make the client think the player count is 50.
    Last edited: Aug 19, 2015
    CrazedMiner likes this.
  6. Legoboy0215
    Offline

    Legoboy0215 Notable Member

    Joined:
    Nov 1, 2014
    Posts:
    1,747
    Minecraft User:
    Legoboy0215
    You are right but QueryRegenerateEvent will trigger it self in a few ticks. You know, these are cheating player counts...
    CrazedMiner likes this.
  7. jojoe77777
    Offline

    jojoe77777 Notable Member Plugin Developer

    Joined:
    May 28, 2015
    Posts:
    653
    Plugins:
    1
    Minecraft User:
    jojoe77777
    Wait, do you mean like text? Or just numbers?
  8. CrazedMiner
    Offline

    CrazedMiner Notable Member Plugin Developer

    Joined:
    Jan 31, 2015
    Posts:
    348
    Plugins:
    2
    Minecraft User:
    CrazedMinerYT
    I'm not cheating player counts, I want to know how to combine them from multiple servers and apply color to them :p
  9. jojoe77777
    Offline

    jojoe77777 Notable Member Plugin Developer

    Joined:
    May 28, 2015
    Posts:
    653
    Plugins:
    1
    Minecraft User:
    jojoe77777
    Oh, I don't think you can apply colors
  10. Legoboy0215
    Offline

    Legoboy0215 Notable Member

    Joined:
    Nov 1, 2014
    Posts:
    1,747
    Minecraft User:
    Legoboy0215
    I dont think so too.
  11. CrazedMiner
    Offline

    CrazedMiner Notable Member Plugin Developer

    Joined:
    Jan 31, 2015
    Posts:
    348
    Plugins:
    2
    Minecraft User:
    CrazedMinerYT
    You van't apply colors, you are only able to set the count's as numbers.
  12. Legoboy0215
    Offline

    Legoboy0215 Notable Member

    Joined:
    Nov 1, 2014
    Posts:
    1,747
    Minecraft User:
    Legoboy0215
    Why are you telling that to me? xD
  13. PEMapModder
    Offline

    PEMapModder Notable Member Plugin Developer

    Joined:
    Oct 9, 2013
    Posts:
    7,325
    Plugins:
    11
    Minecraft User:
    PEMapModder
    You can use $server->getQueryInformation()->setPlayerCount() too.
    PHP is not JavaScript. You need semicolons to terminate statements.
    CrazedMiner likes this.
  14. Primus
    Offline

    Primus Notable Member

    Joined:
    Apr 7, 2015
    Posts:
    1,472
    Minecraft User:
    PrimusLV
    Statements? or lines?
  15. PEMapModder
    Offline

    PEMapModder Notable Member Plugin Developer

    Joined:
    Oct 9, 2013
    Posts:
    7,325
    Plugins:
    11
    Minecraft User:
    PEMapModder
    Statements. A single statement, a.k.a. "line of code", can actually span across several lines, like this:
    PHP:
    $effect Effect::getEffect(Effect::JUMP)
        ->
    setDuration(0x7FFFFF)
        ->
    setAmplitude(1)
        ->
    setVisible(false);
    CrazedMiner likes this.
  16. Primus
    Offline

    Primus Notable Member

    Joined:
    Apr 7, 2015
    Posts:
    1,472
    Minecraft User:
    PrimusLV
    So it's not necessary to put ';' at end of second and third line?
  17. PEMapModder
    Offline

    PEMapModder Notable Member Plugin Developer

    Joined:
    Oct 9, 2013
    Posts:
    7,325
    Plugins:
    11
    Minecraft User:
    PEMapModder
    Not that they are "not necessary", but they are the same statement.
    The set*** functions in Effect return $this. We call another method upon the object, but we are still using the return value from the previous function. They are still the same statement. You can strip out the spaces and line breaks and put the on the same line. Line breaks make no difference on PHP.
  18. jojoe77777
    Offline

    jojoe77777 Notable Member Plugin Developer

    Joined:
    May 28, 2015
    Posts:
    653
    Plugins:
    1
    Minecraft User:
    jojoe77777
    Whoops, edited that now.
  19. basprohop
    Offline

    basprohop Active Member Plugin Developer

    Joined:
    Aug 8, 2015
    Posts:
    128
    Plugins:
    3
    Minecraft User:
    basprohop
    Andrey Nazarchuk likes this.

Share This Page

Advertisement