Monk Posted April 24, 2006 Share Posted April 24, 2006 I wrote this because I needed to see how many servers on a specific gametype I have. I needed it also to dump to html if I needed to (you can probably get creative and replace the $html to an ARGV line, tho) <div class="pre"><pre> <?php $html = 0; mysql_connect("localhost", "tcadmin", "password") or die("Could not connect: " . mysql_error()); mysql_select_db("tcadmin"); $result = mysql_query("SELECT NAME, COUNT(*) AS COUNT FROM tc_services, tc_games WHERE tc_services.game_id = tc_games.game_id GROUP by NAME"); if ( ! $html ) { while ($row = mysql_fetch_array($result, MYSQL_NUM)) { printf("%s %s\n",$row[0], $row[1]); } } else { echo "<table border=1>\n"; echo "<tr><td>Gametype</td><td># of Servers</td></tr>\n"; while ($row = mysql_fetch_array($result, MYSQL_NUM)) { printf("<tr><td>%s</td><td>%s</td></tr>\n",$row[0], $row[1]); } } mysql_free_result($result); ?> </pre></div> Sample console output (where xxx = number of servers) <div class="pre"><pre> Battlefield 2 xxx Call of Duty xxx Call of Duty 2 xx Call Of Duty: United Offensive xxx Condition Zero xxx Counter Strike xxx Counter Strike Boosted xxxx Counter Strike Half Boosted xxx Counter Strike Premium xxx CS Source xxx Day of Defeat xxx Day of Defeat: Source xxx Generic xxx HLTV xxxx Medal of Honor xxx Quake 3 xxx Quake 4 xxx Soldier of Fortune II xxx Star Wars Jedi Knight II: Jedi Outcast xxx Unreal Tournament 2004 xxx Ventrilo 2.3.0 xxx Wolfenstein: Enemy Territory xxxx </pre></div> Link to comment Share on other sites More sharing options...
kalyse Posted April 24, 2006 Share Posted April 24, 2006 Good job, should be useful. I havent looked at the database yet although I definately will do after seeing its this simple to get information you require. Thanks Link to comment Share on other sites More sharing options...
GameConnectors Posted April 25, 2006 Share Posted April 25, 2006 Looks like an easy way of retrieving the total number of servers running, and I notice that Ventrillo is held in tc_services. Does that mean that Teamspeak is also held in there? Link to comment Share on other sites More sharing options...
Monk Posted April 25, 2006 Author Share Posted April 25, 2006 If it's a service, it will show. What i posted is an example, so YMMV, depending on what you have installed as a service. Link to comment Share on other sites More sharing options...
GameConnectors Posted April 25, 2006 Share Posted April 25, 2006 OK, thanks. Think I'll have a play with the DB tonight Link to comment Share on other sites More sharing options...
LFA Posted May 2, 2006 Share Posted May 2, 2006 Looks like an easy way of retrieving the total number of servers running, and I notice that Ventrillo is held in tc_services. Does that mean that Teamspeak is also held in there? Teamspeak servers are stored in TC_VIRTUAL_VOICE_SERVERS Master voice server info is in TC_MASTER_VOICE_SERVERS Link to comment Share on other sites More sharing options...
GameConnectors Posted May 2, 2006 Share Posted May 2, 2006 Excellent, thanks for the info Luis. I still haven't had the chance to look at it yet, but I will do. Link to comment Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.