0) { $query = "select pid, rank, prevrank from uts_rank where gid = $game_id order by rank desc limit $num_players"; $result = mysql_query($query); if (mysql_num_rows($result) > 0) { println('beginlist "'.str_replace('"', '\\"', $list_title).'"'); } while (($r = mysql_fetch_array($result)) && $player_count < MAX_NUMBER_OF_PLAYERS) { // Get player rank info. $player_id = $r['pid']; $rank = $r['rank']; $previous_rank = $r['prevrank']; // Get player info. $query = "select name, country from uts_pinfo where id = $player_id limit 1"; $result2 = mysql_query($query); $r2 = mysql_fetch_array($result2); $player_name = $r2['name']; $player_country = $r2['country']; mysql_free_result($result2); if (substr($player_name, -1) == '\\') { $player_name .= ' '; } // Process data. if ($rank > $previous_rank) { $rank_change = 'up'; } else if ($rank < $previous_rank) { $rank_change = 'down'; } else { $rank_change = 'nc'; } // Echo player info. println('addplayer "'.str_replace('"', '\\"', $player_name).'" '.round($rank).' '.$player_country.' '.$rank_change); // Continue with next player. $player_count++; } mysql_free_result($result); } /////GET BY FRAGS if ("FRAGS" == strtoupper($game_name)) { $query = "SELECT pi.name AS name, pi.country AS country, p.pid, COUNT(p.id) AS games, SUM(p.gamescore) as gamescore, SUM(p.frags) AS frags, SUM(p.kills) AS kills, SUM(p.deaths) AS deaths, SUM(p.suicides) as suicides, AVG(p.eff) AS eff, AVG(p.accuracy) AS accuracy, AVG(p.ttl) AS ttl, SUM(gametime) as gametime FROM uts_player AS p, uts_pinfo AS pi WHERE p.pid = pi.id AND pi.banned <> 'Y' GROUP BY p.pid ORDER BY frags DESC LIMIT $num_players"; $result = mysql_query($query); if (mysql_num_rows($result) > 0) { println('beginlist "'.str_replace('"', '\\"', $list_title).'"'); } while (($r = mysql_fetch_array($result)) && $player_count < MAX_NUMBER_OF_PLAYERS) { // Get player rank info. $player_id = $r['pid']; // Get player info. $query = "select name, country from uts_pinfo where id = $player_id limit 1"; $result2 = mysql_query($query); $r2 = mysql_fetch_array($result2); $player_name = $r2['name']; $player_country = $r2['country']; mysql_free_result($result2); if (substr($player_name, -1) == '\\') { $player_name .= ' '; } If ($r['frags'] > 9999) { $frags = $r['frags'] / 1000; $frags = substr($frags,0,5); $frags = $frags."k"; } else { $frags = $r['frags']; } // Echo player info. println('addplayer "'.str_replace('"', '\\"', $player_name).'" '.$frags.' '.$player_country.' '.$rank_change); // Continue with next player. $player_count++; } mysql_free_result($result); } // Continue with next list. $player_list_index++; } // End of execution, no more output is desired! die(); /***** FUNCTIONS *****/ /*************************************************************************************************** * * $DESCRIPTION Adds a new player list that will be displayed on the server. * $PARAM $game_name The name of the game type. * $PARAM $num_players Number of players to display in the list. * $PARAM $list_title Display title of the list on server. * **************************************************************************************************/ function add_player_list($db_host, $db_name, $db_user, $db_password, $game_name, $num_players = 10, $list_title = '') { global $player_lists; if (trim($list_title) == '') { $list_title = $game_name; } $player_lists[] = array('game_name' => $game_name, 'num_players' => $num_players, 'list_title' => $list_title, 'db_host' => $db_host, 'db_name' => $db_name, 'db_user' => $db_user, 'db_password' => $db_password); } /*************************************************************************************************** * * $DESCRIPTION Writes a line to the output. * $PARAM $text The text that is to be written. * **************************************************************************************************/ function println($text) { echo $text."\r\n"; } ?>