
Ich versuche seit einigen Tagen eine Live Statistik für Call of Duty an das Template System von PHPBB2 anzupassen. Das Original schaut so und mein bisheriges Ergebnis so aus. Im Original wird der kplt. HTML Teil in der PHP Datei erstellt. Ich habe dies getrennt in die call_of_duty_stat.php die alles startet, ein Template call_of_duty_stat.tpl und eine Sprachdatei lang_call_of_duty_stat.php.
Aktuell hänge ich an 2 Problemen fest. Zum einen wird in der Spielerliste nur ein Spieler angezeigt, obwohl mehrere online sind. Der Originalcode sieht dazu so aus:
Code: Alles auswählen
$last_value = count($output) - 1;
$players_string = $output[$last_value];
$players_string = explode("\n", $players_string);
for ($i = 1; $i != count($players_string); $i++) {
$split = explode(" ", $players_string[$i], 3);
$playerlist[$i-1]['score'] = $split[0];
$playerlist[$i-1]['ping'] = $split[1];
$playerlist[$i-1]['player'] = $split[2];
}
function cmp ($a, $b) {
if ($a["score"] > $b["score"]) {
return -1;
}
if ($a["score"] < $b["score"]) {
return 1;
}
if ($a["score"] == $b["score"]) {
return 0;
}
}
@usort($playerlist, "cmp");
$players = count($playerlist) - 1;
[...]
<?
for ($i = 0; $i != (count($playerlist) -1); $i++) {
?>
<tr>
<td><?=farben(str_replace("\"", "", $playerlist[$i]['player']))?></td>
<td width="54"><?=$playerlist[$i]['score']?></td>
<td width="64"><?=$playerlist[$i]['ping']?></td>
</tr>
<? } ?>
Code: Alles auswählen
$last_value = count($output) - 1;
$players_string = $output[$last_value];
$players_string = explode("\n", $players_string);
for ($i = 1; $i != count($players_string); $i++)
{
$split = explode(" ", $players_string[$i], 3);
$playerlist[$i-1]['score'] = $split[0];
$playerlist[$i-1]['ping'] = $split[1];
$playerlist[$i-1]['player'] = $split[2];
}
function cmp ($a, $b)
{
if ($a["score"] > $b["score"])
{
return -1;
}
if ($a["score"] < $b["score"])
{
return 1;
}
if ($a["score"] == $b["score"])
{
return 0;
}
}
@usort($playerlist, "cmp");
$players = count($playerlist) - 1;
}
for ($i = 0; $i != (count($playerlist) -1); $i++)
{
$template->assign_vars(array(
'PLAYER' => farben(str_replace("\"", "", $playerlist[$i]['player'])),
'PLAYER_SCORE' => $playerlist[$i]['score'],
'PLAYER_PING' => $playerlist[$i]['ping']));
}

Code: Alles auswählen
<table width="400" border="0" cellpadding="0" cellspacing="1" align="center">
<tr>
<td class="row1" align="center" height="20"><span class="explaintitle">{L_GAMER_NAME}</span></td>
<td class="row1" align="center" height="20"><span class="explaintitle">{L_GAMER_POINT}</span></td>
<td class="row1" align="center" height="20"><span class="explaintitle">{L_GAMER_PING}</span></td>
</tr>
<tr>
<td class="row2" align="center" height="20">{PLAYER}</td>
<td class="row2" width="54" align="center" height="20">{PLAYER_SCORE}</td>
<td class="row2" width="64" align="center" height="20">{PLAYER_PING}</td>
</tr>
</table>