Hvordan får jeg lige lavet den sortering/udskillelse ?
Specielt efter "// Find players equal to members (on our own now + leaning to the supercoders scripting)"
Som I kan se har jeg ZERO forstand på PHP, men jeg prøver..
// Get Class CounterStrike Author : Henrik Schack Jensen (henrik@schack.dk)
// Demosource is available at
http://www.gameserver.dk/// The function I believe to be the one I need for this to work..??? but not sure
// Its from the file counterstrike.php
// **********************************************************************
// Get Playerinfo
// Read information about the players into m_playerinfo
// Name,frags,playtime
// Return true if successful
// **********************************************************************
//function getServerPlayers($serveraddress,$portnumber,$waittime) {
// Servercommand
// $cmd="\xFF\xFF\xFF\xFFplayers\x00";
// $serverdata=$this->getServerData($cmd,$serveraddress,$portnumber,$waittime);
// Check length of returned data, if < 5 something went wrong
// if (strlen($serverdata)<5) return false;
// Check number of players to read data for
// $players=ord($serverdata[5]);
// Strip OOB data and other stuff
// $serverdata=substr($serverdata,7);
// for ($i=1;$i<=$players;$i++) {
// $playername =htmlspecialchars($this->getnextstring($serverdata));
// $frags =$this->getnextfragvalue($serverdata);
// $playtime =$this->getnextplaytime($serverdata);
// $this->m_playerinfo[$i] =array("name"=>$playername,"frags"=>$frags,"time"=>$playtime);
// }
// Sort players in fragorder
// if ($players>1) usort($this->m_playerinfo,"fragsort");
// return true;
// }
// So here we get it.. thank You Henrik Schack Jensen
<? require("../phpclanwebsite/counterstrike.php") ?>
<?
// get mysql login details (now working with phpclanwebsite snippets!)
include "../phpclanwebsite/config.php";
//create connection
$connection = mysql_connect("$mysql_host", "$mysql_login", "$mysql_pass") or die ("Couldnt connect to the server.");
//select database
$db = mysql_select_db("$mysql_database",$connection) or die ("Couldnt select the database.");
// Get members from database
$sql = "SELECT TAG FROM cws_members";
$sql_result = mysql_query($sql,$connection) or die ("Couldnt execute query");
while ($row = mysql_fetch_array($sql_result)) {
$memberson = array();
}
// set vars (back to Schacks code)
<?
$serveradr ="129.142.199.185";
$serverport="27015";
$csinfo=new CounterStrike;
$status=$csinfo->getServerPlayers($HTTP_GET_VARS["serveradr"],$HTTP_GET_VARS["serverport"],1000);
if ($status) {
?>
<TABLE>
<TR>
<TD ALIGN="CENTER" VALIGN="TOP">
<TABLE>
// Find players equal to members (on our own now + leaning to the supercoders scripting)
<? if (is_array($csinfo->m_playerinfo)) { ?>
<?while $result_array = array_intersect((list(,$player) = each ($csinfo->m_playerinfo)), $memberson);?>
<? { ?>
<TR>
<TD><?=$player["name"]?> </TD><TD>IN-GAME</TD>?></TD>
</TR>
<? } ?>
<? } else { ?>
<TR>
<TD><?=$player["name"]?> </TD><TD>OFFLINE</TD>?></TD>
</TR>
<? } ?>
</TABLE>
</TD>
</TR>
</TABLE>
<? } else { ?>
<DIV ALIGN="CENTER">Error</DIV>
<? } ?>