22.02.2012, 17:41
Try this one -
PHP код:
<?php
require "samp_query.php";
$serverIP = "localhost"; // if don't work use 127.0.0.1 or 192.168.1.1
$serverPort = 7777;
try
{
$rQuery = new QueryServer( $serverIP, $serverPort );
$aInformation = $rQuery->GetInfo( );
$aServerRules = $rQuery->GetRules( );
$aBasicPlayer = $rQuery->GetPlayers( );
$aTotalPlayers = $rQuery->GetDetailedPlayers( );
$rQuery->Close( );
}
catch (QueryServerException $pError)
{
echo "Oops! Server Is Currently Offline We'll Be Back Soon. Thanks For Waiting :)";
}
if(isset($aInformation) && is_array($aInformation)){
?>
<b>Server Stats/Information.</b>
<table width="400">
<tr>
<td>NomeServer</td>
<td><?php echo htmlentities($aInformation['Hostname']); ?></td>
</tr>
<tr>
<td>Gamemode</td>
<td><?php echo htmlentities($aInformation['Gamemode']); ?></td>
</tr>
<tr>
<td>Giocatori</td>
<td><?php echo $aInformation['Players']; ?> / <?php echo $aInformation['MaxPlayers']; ?></td>
</tr>
<tr>
<td>Mappa</td>
<td><?php echo htmlentities($aInformation['Map']); ?></td>
</tr>
<tr>
<td>Tempo</td>
<td><?php echo $aServerRules['weather']; ?></td>
</tr>
<tr>
<td>Ora</td>
<td><?php echo $aServerRules['worldtime']; ?></td>
</tr>
<tr>
<td>Versione</td>
<td><?php echo $aServerRules['version']; ?></td>
</tr>
<tr>
<td>Password</td>
<td><?php echo $aInformation['Password'] ? 'Yes' : 'No'; ?></td>
</tr>
<tr>
<td>Web URL</td>
<td><?php echo $aInformation['url']; ?></td>
</tr>
</table>
<br />
<b>Online Players</b>
<?php
if(!is_array($aTotalPlayers) || count($aTotalPlayers) == 0){
echo '<br /><i>Nessuno</i>';
} else {
?>
<table width="400">
<tr>
<td><b>ID Giocatore</b></td>
<td><b>Nickname</b></td>
<td><b>Punteggio</b></td>
<td><b>Ping</b></td>
</tr>
<?php
foreach($aTotalPlayers AS $id => $value){
?>
<tr>
<td><?php echo $value['PlayerID']; ?></td>
<td><?php echo htmlentities($value['Nickname']); ?></td>
<td><?php echo $value['Score']; ?></td>
<td><?php echo $value['Ping']; ?></td>
</tr>
<?php
}
echo '</table>';
}
}
?>