2014-04-22 35 views
0

我下載從這裏的代碼:我想回聲出服務器的MOTD,與此代碼https://github.com/FunnyItsElmo/PHP-Minecraft-Server-Status-Query的Minecraft服務器查詢不附和MOTD

<?php 

include_once 'get.php'; //include the class 
$status = new MinecraftServerStatus(); // call the class 

$response = $status->getStatus('localhost'); // call the function 

$statusTxt = "offline"; 
$version ="N/A"; 
$ping ="N/A"; 
$players = "0/0"; 
$host = "N/A"; 
$motd = "N/A"; 
$version= "N/A"; 

if($response){ 
    $statusTxt="online"; 
    $players = $response['players'] . "/" . $response['maxplayers']; 
    $version = $response['version']; 
    $ping = $response['ping']; 
    $host = $response['hostname']; 
    $motd = $response['motd']; 
    $version = $response['version']; 
} 

?> 
<div id="banner"> 
<div id="status"><?php 
echo$statusTxt; 
?></div> 
<div id="version"><?php 
echo$version; 
?></div> 
<div id="ping"><?php 
echo$ping; 
?></div> 
<div id="players"><?php 
echo$players; 
?></div> 
<div id="host"><?php 
echo $host; 
?></div> 
<div id="motd"><?php 
echo $motd; echo $version; 
?></div> 
</div> 

但返回:

online 
103 
3/100 
localhost 
1.7.5 

我該如何迴應服務器的MOTD?

+0

您的MOTD是否有任何奇怪的字符或顏色代碼? – Jono20201

+0

@ Jono20201,是 – user3032715

+0

嘗試改變你的MOTD簡單,然後看看它是否工作。我沒有看到任何其他原因,爲什麼不顯示。 – Jono20201

回答

0

我建議只使用Auto Bukkit,它對於Minecraft服務器來說非常簡單,MOTD在100%的時間內工作。