Jump to content

Live Stats MySQL Query


votick

Recommended Posts

  • 4 weeks later...
  • 4 months later...

Anyone got a script for showing stats for servers owned by a certian user id.

 

E.g. I want to show the status and player count on a website for demo servers owned by the admin account.

 

I seem to get multiple results for the same server (some wrong).

 

GMod Server (0/0)

GMod Server (0/0)

GMod Server (0/)

GMod Server (0/)

GMod Server (2/6)

GMod Server (2/6)

GMod Server (0/8)

GMod Server (0/8)

GMod Server (0/0)

GMod Server (0/0)

 

And I can't seem to grab the ip or port from the mysql table.

 

I'll give it another shot tomorrow.

Link to comment
Share on other sites

Here's what I have t the moment:

 

<?php
mysql_connect("ADDRESS", "USER", "PASSWORD") or die(mysql_error());
mysql_select_db("DATABASE") or die(mysql_error());
$result = mysql_query("SELECT s.ip_address,s.game_port,g.display_name,g.query_protocol,g.game_id,ls.online,ls.map,ls.name,ls.max_players,ls.players,ls.service_id
FROM tc_game_services s
INNER JOIN tc_games g ON s.game_id = g.game_id
INNER JOIN tc_game_service_live_stats ls ON s.service_id = ls.service_id
WHERE online = 1
ORDER BY g.display_name ASC, ls.name ASC") or die(mysql_error());
while($row = mysql_fetch_array($result)){
   echo "<li><img src='images/gameimages/mini/16/" . $row['game_id'] . ".png' border='0' width='16px' height='16px' /> <a href='http://www.gametracker.com/server_info/" . $row['ip_address'] . ":" . $row['game_port'] . "' target='_blank'>" . $row['ip_address'] . ":" . $row['game_port'] . "</a> (" . $row['players'] . "/" . $row['max_players'] . ")</li>";
} 
?>

 

So I have the address and online/max slots. Only thing I'm having trouble with is showing only the results by userid 15.

 

Anyone shed any light?

Link to comment
Share on other sites

  • 7 months later...
  • 1 month later...

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
  • Who's Online   0 Members, 0 Anonymous, 26 Guests (See full list)

    • There are no registered users currently online
×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue. Terms of Use