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

Playercount

Discussion in 'Facepalm' started by #A6543, Mar 11, 2017.

Thread Status:
Not open for further replies.
  1. #A6543

    #A6543 Zombie

    Messages:
    267
    How can I get the max and online players count of a specific server?

    (Not the server where the plugin is)
     
  2. Teamblocket

    Teamblocket Zombie

    Messages:
    301
    GitHub:
    teamblocket
    PHP:
    $this->plugin->getServer()->getOnlinePlayers()
    PHP:
    $this->plugin->getServer()->getMaxPlayers()
     
    TheDiamondYT likes this.
  3. Thunder33345

    Thunder33345 Moderator Staff Member

    Messages:
    2,137
    GitHub:
    Thunder33345
     
    #A6543 and HimbeersaftLP like this.
  4. #A6543

    #A6543 Zombie

    Messages:
    267
    I tried the Php Query by xPaw. But when a player joins, he gets a timeout. (no error). But I can get the infos using that
     
  5. Thunder33345

    Thunder33345 Moderator Staff Member

    Messages:
    2,137
    GitHub:
    Thunder33345
    Oh no, you should query that on an async task
    also it wont work if the server disabled the count
     
  6. #A6543

    #A6543 Zombie

    Messages:
    267
    Can u give me an example?
     
  7. Kyd

    Kyd Zombie Pigman

    Messages:
    678
    GitHub:
    boi1216
    http://minecraft-api.com
     
  8. #A6543

    #A6543 Zombie

    Messages:
    267
    How can I get the infos in a AsyncTask? Can someone give me an example?
     
  9. Kyd

    Kyd Zombie Pigman

    Messages:
    678
    GitHub:
    boi1216
    PHP:
    $playeronline file_get_contents('http://minecraft-api.com/api/query/playeronline.php?ip=VOTRE.IP&port=VOTRE.PORT'); 
    echo 
    $playeronline
     
  10. #A6543

    #A6543 Zombie

    Messages:
    267
    Error: failed to open stream: Unable to find the socket transport

    (I'm using Linux)
     
  11. Thunder33345

    Thunder33345 Moderator Staff Member

    Messages:
    2,137
    GitHub:
    Thunder33345
    to be honest, i have no clue
    but i think it invlove notifying the base plugin with the info
     
  12. #A6543

    #A6543 Zombie

    Messages:
    267
    Do u know what code they used?
     
  13. Kyd

    Kyd Zombie Pigman

    Messages:
    678
    GitHub:
    boi1216
    No, You asking how to get number of player, so use the website?
     
  14. #A6543

    #A6543 Zombie

    Messages:
    267
    Read what I wrote....

    Error: failed to open stream: Unable to find the socket transport
     
  15. Kyd

    Kyd Zombie Pigman

    Messages:
    678
    GitHub:
    boi1216
    Have you tested if website can connect to your server?
    ...
     
  16. #A6543

    #A6543 Zombie

    Messages:
    267
    I added the count on my own website (without SSL). Now it works. But isn't there a method with less lag?
     
  17. Jack Noordhuis

    Jack Noordhuis Zombie Pigman Poggit Reviewer

    Messages:
    618
    GitHub:
    JackNoordhuis
    Use an async task or some other sort of threading solution so the main thread doesn't freeze while it waits for the response.
     
  18. #A6543

    #A6543 Zombie

    Messages:
    267
    That sounds like what I need! But how can I do that? I already searched for it... No result :/
     
  19. SOFe

    SOFe Administrator Staff Member PMMP Team Poggit Admin

    Messages:
    1,968
    GitHub:
    sof3
    Asked for countless times. Refer to previous threads for further discussion.
     
Thread Status:
Not open for further replies.
  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.