Jump to content
Fórum Script Brasil
  • 0

[Ajuda] Mostrar status do servidor


SkyBR

Question

Olá,

Estou com um problema, tenho um servidor de games e estou querendo mostrar o status dele e quantos jogadores estão online, o codigo já está hospedado no wamp, possuo noip, mas só funciona local, tipow local ele mostra o servidor online com é pra ser, mas quando coloco de fora ele não faz conexão com o servidor ele sempre mostra offline!

noip: skyterraria.no-ip.biz

porta api: 7878

porta do jogo: 7777

hospedagem:

http://skyterraria.no-ip:8090/Status/tshock.php?ip=<ip>&port=<port api>
Local: imagem2w.png Externo: imagem1wd.png
<?php
error_reporting(E_ERROR);
$ip = $_GET['ip'];
$port = $_GET['port'];
$json = json_decode(file_get_contents('http://'.$ip.':'.$port.'/status/'), true);
header('Content-Type: image/png');
$im = @imagecreatefrompng('tshock_status_background.png');
$font = 'visitor1.ttf';
$red = imagecolorallocate($im, 0xFF, 0, 0);
$grey = imagecolorallocate($im, 128, 128, 128);
if ($json['status'] == '200')
{
    imagettftext($im, 20, 0, 11, 26, $grey, $font, $json['name']);
    imagettftext($im, 20, 0, 10, 25, $black, $font, $json['name']);
    imagettftext($im, 15, 0, 11, 41, $grey, $font, 'IP: '.$ip);
    imagettftext($im, 15, 0, 10, 40, $black, $font, 'IP: '.$ip);
    imagettftext($im, 15, 0, 11, 61, $grey, $font, 'Port: '.$json['port']);
    imagettftext($im, 15, 0, 10, 60, $black, $font, 'Port: '.$json['port']);
    imagettftext($im, 15, 0, 11, 81, $grey, $font, 'Players: '.$json['playercount']);
    imagettftext($im, 15, 0, 10, 80, $black, $font, 'Players: '.$json['playercount']);
}
else
{
    imagettftext($im, 15, 0, 11, 21, $grey, $font, 'IP:'.$ip.':'.$port);
    imagettftext($im, 15, 0, 10, 20, $black, $font, 'IP:'.$ip.':'.$port);
    imagettftext($im, 78, 0, 10, 90, $red, $font, 'offline');
}
imagepng($im);
imagedestroy($im);
?>

Link to comment
Share on other sites

2 answers to this question

Recommended Posts

  • 0

tente assim

<?php
$ping = @fsockopen ("servename.no-ip.info", porta, $errno, $errstr, 30);
        if($ping) 
                { 
                        echo 'Login Server Offline'; 
                }
        else 
                { 
                        echo 'Login Server Online'; 
                }
        
?>

para entende melhor ... não é complicado ^^

http://php.net/manual/pt_BR/function.fsockopen.php

Edited by JaguA
Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Answer this question...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.



  • Forum Statistics

    • Total Topics
      152.2k
    • Total Posts
      652k
×
×
  • Create New...