13
0
300 €
This is our monthly target.
Please visit our donations page for more details.
Please visit our donations page for more details.
chmod a+rw cache/4. Configuration Open the config.php file in your favourite editor. You will find 4 configuration variables: $servers This is list of the servers to display. You have to fill out name, IP address and port for each server. For example, here is the list we are using:
$servers = array (array ('name' => 'Server #1 [TF2 - All maps]',
'ip' => '85.17.60.96',
'port' => 27025),
array ('name' => 'Server #2 [TF2 - All maps]',
'ip' => '85.17.60.96',
'port' => 27035),
array ('name' => 'Server #3 [TF2 - All maps]',
'ip' => '85.17.60.102',
'port' => 27015),
array ('name' => 'Server #4 [TF2 - Dustbowl]',
'ip' => '80.193.86.252',
'port' => 27015));
$cachelifetime
This sets the time (in seconds) after which the cache file expires. Default value is 30 seconds. Setting it higher will reduce server load but it'll be "less live" and vice-versa. To disable caching set it to 0.
$cachefile
Path to the cache file. You probably won't need to change this one.
$output
This is something like template. For each server, this text will be filled with actual data and sent to browser. You can use the following placeholders:
steam://connect/#ip#:#port#
<script src="jquery.js" type="text/javascript"></script>Note: Don't forget to change the src attribute if you have jquery.js in some subdirectory. Then put the following code anywhere to your website where you want the stats to be located:
<div id="serverstats-loading">Please wait ...<br /></div> <div id="serverstats-wrapper" style="display: none"></div>The first <div> will be displayed until server info is loaded. Then the second <div> will be filled with the output of query.php and displayed. All this is done by the following JavaScript code (put it at the end of your website, before </body>):
<script type="text/javascript">
$(document).ready(function(){
$.post("query.php", {},
function (data) {
$('#serverstats-wrapper').html (data);
$('#serverstats-loading').hide();
$('#serverstats-wrapper').show ();
});
});
</script>
Note: Again, don't forget do change the path to query.php if it's located in some subdirectory.
If you want the same expanding effect as we have on our website, change this line:
$('#serverstats-wrapper').show ();
to
$('#serverstats-wrapper').show ("slow");
7. Conclusion
Now you know how to put live server stats on your website. If you found this How-To useful, please recommend it to others. Also, if you have any problems with getting this work or you have some other questions, feel free to ask in comments.
Comments
hi
21. February 2009 - 13:26 — Anonymousvery nice tip ;)
how to show playing user and map picture ?
Live server stats on your website
13. October 2008 - 15:59 — AnonymousI browsed through the
13. October 2008 - 15:58 — AnonymousI'd like to know how to make
20. August 2008 - 23:42 — AnonymousNot querying properly
15. August 2008 - 4:33 — AnonymousLooks like you are using the
16. August 2008 - 9:28 — lacop (not verified)www.odr66.com/phpinfo.php its
31. August 2008 - 20:27 — AnonymousI got the same problem he had
20. August 2008 - 10:50 — AnonymousError message
2. August 2008 - 15:22 — AnonymousError Message - config.php
28. August 2008 - 1:36 — Anonymousplease post your config.php
2. August 2008 - 16:30 — lacop (not verified)ok...pasted as requested (out
2. August 2008 - 16:39 — Anonymousfixed
2. August 2008 - 19:53 — lacop (not verified)Worked like a charm -
3. August 2008 - 14:33 — Anonymouscheck source of this
3. August 2008 - 20:47 — lacop (not verified)OK....I feel like a total
4. August 2008 - 13:57 — Anonymousall you need is to change the
5. August 2008 - 16:21 — lacop (not verified)How would I add timeleft and
21. August 2008 - 1:06 — Anonymous