Commit 7f4442db authored by Stuart John Watson's avatar Stuart John Watson

Modified return structure for number of players

Added it to the displayed infomation
parent da60937d
......@@ -43,10 +43,13 @@ function minecraft(){
return [
"online"=>true,
"description"=>$result["description"],
"playersCount"=>$result["players"]["online"],
"playersMax"=>$result["players"]["max"],
"players"=>$players,
"version"=>$result["version"]["name"]
"players"=>[
"current"=>$result["players"]["online"],
"max"=>$result["players"]["max"],
"list"=>$players
],
"version"=>$result["version"]["name"],
"extra"=>"<a href='http://games.sucs.org/dynmap'>Live Map</a>"
];
}
......
......@@ -61,14 +61,14 @@ function openTTD(){
$mapSet = $info4[2];
$dedicated = $info4[3];
return [
"online"=>true,
"description"=>$serverName,
"map"=>$mapName,
"playersCount"=>$clientsOn,
"playersMax"=>$clientsMax
"players"=>[
"current"=>$clientsOn,
"max"=>$clientsMax
]
];
}
......
......@@ -75,8 +75,7 @@ function sauerbraten(){
"online"=>true,
"description"=>$serverDesc,
"map"=>$mapName,
"playersCount"=>$numPlayers,
"playersMax"=>$maxClients,
"players"=>["current"=>$numPlayers,"max"=>$maxClients],
"gameMode"=>$gameMode
];
}
......
......@@ -318,17 +318,25 @@ include "gamesCheck/sauerbraten.php";
$data = [
"Minecraft" => minecraft(),
"OpenTTD" => openTTD(),
"sauerbraten" => sauerbraten()];
"Sauerbraten" => sauerbraten()];
foreach ($data as $name=>$result){
if ($result["extra"]){
$extra = "<p>".$result["extra"]."</p>";
} else {
$extra = "";
}
if ($result["online"]){
$description = $result["description"];
$playersOn = $result["players"]["current"];
$playersMax = $result["players"]["max"];
echo("
<div class=\"col-md-4\">
<div class=\"panel panel-default\">
<div class=\"panel-body\">
<h2>$name - <font color=\"green\">Online</font></h2>
<p>
${result["description"]};
</p>
<p>$description</p>
<p>$playersOn/$playersMax Players Online</p>
$extra
</div>
</div>
</div>
......@@ -339,9 +347,8 @@ foreach ($data as $name=>$result){
<div class=\"panel panel-default\">
<div class=\"panel-body\">
<h2>$name - <font color=\"red\">Offline</font></h2>
<p>
${result["error"]};
</p>
<p>${result["error"]}</p>
$extra
</div>
</div>
</div>
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment