It's not working quite right...
function update_status_cache($force_update = false)
{
if($force_update || count($this->status_cache) == 0)
{
$this->send_ctrl("status");
$data = $this->get_ctrl();
// Example data:
// \TimeLeft\14:32\pr\!0\mapname\arenaball\_scores\Red:0 Blue:0
// 0 204 "JoeJoe"
$result = explode("\n", $data);
$status = explode("\\", $result[0]);
// Knock off the status data (so we can get the player list)
array_shift($result);
// Knock off the first blank entry
array_shift($status);
// Get the key/value statusness
$info = array();
// We skip two, so we set:
// key = i
// value = i+1
for($i = 0; $i < count($status); $i += 2)
{
$info[$status[$i]] = trim($status[$i+1]);
}
$this->status_cache = $info;
// Get the player list
$players = array();
$index = 0;
foreach($result as $line)
{
$line = trim($line);
$line = explode(" ", $line, 3);
if(!$line[2]) continue;
if(strpos($info['pr']."!", "!$index!") !== false)
$team = TEAM_RED;
else if(strpos($info['pb']."!", "!$index!") !== false)
$team = TEAM_BLUE;
else if(strpos($info['py']."!", "!$index!") !== false)
$team = TEAM_YELLOW;
else if(strpos($info['pp']."!", "!$index!") !== false)
$team = TEAM_PURPLE;
else
$team = TEAM_OBSERVER;
$players[] = array('name' => substr($line[2], 1, -1),
'ping' => $line[1],
'score' => $line[0],
'team' => $team);
$index++;
}
$this->players_cache = $players;
}
}
Or if you don't want to read that code, mind telling me how it's done?