Skocz do zawartości
  • 👋 Witaj na MPCForum!

    Przeglądasz forum jako gość, co oznacza, że wiele świetnych funkcji jest jeszcze przed Tobą! 😎

    • Pełny dostęp do działów i ukrytych treści
    • Możliwość pisania i odpowiadania w tematach
    • System prywatnych wiadomości
    • Zbieranie reputacji i rozwijanie swojego profilu
    • Członkostwo w jednej z największych społeczności graczy

    👉 Dołączenie zajmie Ci mniej niż minutę – a zyskasz znacznie więcej!

    Zarejestruj się teraz

Rekomendowane odpowiedzi

Opublikowano

Możesz sobie zrobić forum i wgrać banner, który pokazuje ile osób jest Online.

============================================================

 

Jeśli ci pomogłem daj like :)

 

===================================================================

Opublikowano


 

<?

class status {

 

private $address;

private $port;

 

public function __construct($address, $port = 25565){

$this->address = $address;

$this->port = $port;

}

 

public function get_ping_info(&$dane){

$socket = @fsockopen($this->address, $this->port, $errno, $errstr, 1.0);

 

if ($socket === false){

return false;

}

 

fwrite($socket, "\xfe\x01");

 

$data = fread($socket, 256);

 

if (substr($data, 0, 1) != "\xff"){

return false;

}

 

if (substr($data, 3, 5) == "\x00\xa7\x00\x31\x00"){

$data = explode("\x00", mb_convert_encoding(substr($data, 15), 'UTF-8', 'UCS-2'));

}else{

$data = explode('§', mb_convert_encoding(substr($data, 3), 'UTF-8', 'UCS-2'));

}

 

if (count($data) == 3){

$dane = array(

'players' => intval($data[1]),

'max_players' => intval($data[2]),

);

}else{

$dane = array(

'players' => intval($data[2]),

'max_players' => intval($data[3]),

);

}

 

return true;

}

 

}

 

$server = new status('TUTAJ_PODAJ_IP', 25565);

 

if (!$server->get_ping_info($dane)){

}else{

print_r($dane);

}

?>

 

Pomogłem?👍

Daj Like! :D

Opublikowano

 


<?
class status {
 
    private $address;
    private $port;
 
    public function __construct($address, $port = 25565){
        $this->address = $address;
        $this->port = $port;
    }
 
    public function get_ping_info(&$dane){
        $socket = @fsockopen($this->address, $this->port, $errno, $errstr, 1.0);
     
        if ($socket === false){
            return false;
        }
     
        fwrite($socket, "\xfe\x01");
     
        $data = fread($socket, 256);
     
        if (substr($data, 0, 1) != "\xff"){
            return false;
        }
     
        if (substr($data, 3, 5) == "\x00\xa7\x00\x31\x00"){
            $data = explode("\x00", mb_convert_encoding(substr($data, 15), 'UTF-8', 'UCS-2'));
        }else{
            $data = explode('§', mb_convert_encoding(substr($data, 3), 'UTF-8', 'UCS-2'));
        }
     
        if (count($data) == 3){
            $dane = array(
                'players'        => intval($data[1]),
                'max_players'    => intval($data[2]),
            );
        }else{
            $dane = array(
                'players'        => intval($data[2]),
                'max_players'    => intval($data[3]),
            );
        }
     
        return true;
    }
 
}
 
$server = new status('TUTAJ_PODAJ_IP', 25565);
 
if (!$server->get_ping_info($dane)){
}else{
    print_r($dane);
}
?>

Dziala ale pokazuje sie to "Array([players] => 0[max_players] => 60)" Nie da sie zrobic tak zeby pokazywalo "0/60"?

Z gory dzieki i juz like dalem

Zarchiwizowany

Ten temat przebywa obecnie w archiwum. Dodawanie nowych odpowiedzi zostało zablokowane.

×
×
  • Dodaj nową pozycję...