Solved List players with php scripts?

Discussion in 'Bukkit Help' started by XDRosenheim, Jul 9, 2013.

Thread Status:
Not open for further replies.
  1. Offline

    XDRosenheim

    To make it short, I want to make a list of players that are online, I don't care if it is real-time or if you have to refresh the page to update it.
    Many of the problems I have seen was b/c of "free hosting" and not supporting PHP, but this server i have do. (Just so that isn't the case of anything not working)

    Also, if possible, a simple "Online", "Offline" status for the server itself.

    If anyone have something they don't mind sharing, I would be thankful.
     
  2. Offline

    DrMirman620

    If you use Multicraft control panel then there is a banner you can copy the link of and use as a live update. Other sites you could use to make one are:

    http://www.minecraftbanner.com/
    http://minecraftviewer.com/

    Also, take a look at this page: https://forums.bukkit.org/threads/web-minecraft-banner-maker-status-online-players.149856/

    If you want to code your own there will be tutorials out there, I would have a search around.
     
  3. Offline

    XDRosenheim

    Thanks, but it would be great with something fully customize able. That's why I wanted it in PHP.
    If you use a banner (fx. from topg.org) you are forced to use their pictures and their layouts.

    Solved.
    Found this:
    PHP:
    <?php
    $ip 
    '127.0.0.1';
    $port 25565;
     
    $onlinePlayers 0;
    $maxPlayers 0;
    $serverMotd '';
     
    $serverSock = @stream_socket_client('tcp://'.$ip.':'.$port$empty$empty1);
     
     
    if(
    $serverSock !== FALSE)
    {
        
    fwrite($serverSock"\xfe");
       
        
    $response fread($serverSock2048);
        
    $response str_replace("\x00"''$response);
        
    $response substr($response2);
       
        
    $data explode("\xa7"$response);
       
        unset(
    $response);
     
        
    fclose($serverSock);
     
        if(
    sizeof($data) == 3)
        {
            
    $serverMotd $data[0];
            
    $onlinePlayers = (int) $data[1];
            
    $maxPlayers = (int) $data[2];
           
            echo 
    $serverMotd.'<br/>';
            echo 
    $onlinePlayers.'/'.$maxPlayers.' player(s) online.';
        }else{
            echo 
    'Could not connect.';
        }
    }else{
        echo 
    'Server is offline.';
    }
     
    ?>
    EDIT by Moderator: merged posts, please use the edit button instead of double posting.
     
    Last edited by a moderator: Jun 3, 2016
  4. Offline

    Bobcat00

    Enable query in your server.properties, then use this query PHP code:
    https://github.com/xPaw/PHP-Minecraft-Query
    You want MinecraftQuery.class.php

    Besides a list of all the players online (I suggest you sort them with a natural order sort), you can also get a list of all plugins.
     
Thread Status:
Not open for further replies.

Share This Page