21.12.2016, 14:54
Quote:
Hi,
How in php file, check if speficic player is joined to my server? |
note: i did this in 2011 (dont judge! pls ppls)
PHP код:
<?php
$sIP = "localhost";//server IP
$sPORT = 7777;//server Port
require "SampQueryAPIxx.php";
$query = new SampQueryAPI($sIP, $sPORT);
$sInfo = $query->getInfo();
if(!$query->isOnline()) { echo "Server Offline"; exit; }
echo '<meta http-equiv="Content-Type" content="text/html;charset=utf-8" />';
$aPlayers = $query->getDetailedPlayers();
if(!is_array($aPlayers) || count($aPlayers) == 0)
{
echo "<br /><i>well, either something went wrong or there are no players</i>";
}
else
{
?>
<style type="text/css">
thead
{
background-image: url("head.jpg");
}
table
{
margin:35;
border:1px solid #CCC;
border-collapse:collapse;
}
tr.bottom
{
background-image: url("head.jpg");
}
font
{
opacity: 0.0;
font-family:Roman;
color:#cccccc;
}
font.exception
{
opacity: 100.0;
}
p
{
font-family:Arial;
}
td
{
font-family:Verdana;
}
.highlight
{
background-image: url("row.png");
}
.normal
{
background-image: none;
}
.unselectable
{
-webkit-touch-callout: none;
-webkit-user-select: none;
-khtml-user-select: none;
-moz-user-select: -moz-none;
-ms-user-select: none;
user-select: none;
}
</style>
<center>
<p><?= $sInfo['hostname']; ?></p>
<table width="300" name="board" class="unselectable">
<thead class="head">
<td><b>ID</b></td>
<td align=middle><b>Name</b></td>
<td><b>Score</b></td>
<td><b>Ping</b></td>
</thead>
<?php
foreach($aPlayers as $sValue)
{
?>
<tr OnMouseOver="this.className='highlight'" OnMouseOut="this.className='normal'">
<td><?= $sValue['playerid'] ?></td>
<td><?= htmlentities($sValue['nickname']) ?></td>
<td><?= $sValue['score'] ?></td>
<td align=right><?= $sValue['ping'] ?></td>
</tr>
<?php
}
echo '<tr class="bottom"><td><font>.</font></td><td align=right><font class="exception">Autor: East_Crips</font></td><td><font>.</font></td><td><font>.</font></td></tr>';
echo '</table></center>';
}
?>
<!--
East_Crips 2011
!-->
(i jsut put in some random server to demonstrate)
on top is server name and below a table with player ifos
//EDIT: oh and most importantly, get the query API from https://sampforum.blast.hk/showthread.php?tid=104299