Please visit our donations page for more details.
1. Introduction
The long awaited guide how to put live stats to MOTD is here! Make sure you've read our guide How-To: Create a TF2 chalkboard style MOTD with HTML first.
Here is the screenshot of our current MOTD:
2. Requirements
To get this working you'll need:
And a little programming knowledge will come handy for configuration.
3. Download & installation
You can download the script, config and sample MOTD here (ZIP, 228kB). Extract and copy it to your website.
Important: Make sure that directory cache/ is writable by the webserver. You can do this using your FTP client (search for Properties or Permissions) or you can use the following command:
chmod a+rw cache/
4. Configuration
Same as in live server stats for website, everything you need to edit is the config.php file. However, this time you'll find much more settings there so lets go step by step:
$image
Path to the base image. Live stats will be printed over it so prepare image with empty space for them like this:
$cachedir
Directory where cache files will be saved. Don't forget to set the permissions.
$cachelifetime
Time (in seconds) after which cache expires. After mapchange, when lots of players join at once, caching will greatly reduce server load. Setting to 0 will turn caching off.
$timeout and $retries
Script will wait $timeout seconds for response from the server. If time runs out this will be done $retries more times. If there is still no answer, server will be marked offline / down.
If you often get online servers incorrectly marked as offline, try rising these variables.
$nextmap
Server variable (cvar) that contains the name of next map. For SourceMod use the default value sm_nextmap
$timeleft
This variable is very hard to understand without programming and regular expressions knowledge. If you are using SourceMod you are lucky, because the default value will work for you, so you can skip this part.
If you are using some another server plugin you have 3 options: delete this variable and don't use timeleft in your MOTD, configure it yourself or post info about your plugin and it's timeleft command to comments and wait for answer.
If you are going to configure it yourself here is something you should know:
command is name of the command that returns time remaining for current map. outputs is array of regexp => output pairs. If some regexp matches the output of the command, output will be displayed. If no match is found, default is returned.
$xstart and $ystart
Starting coordinates of the live stats (this will be the top-left corner).
$xstep and $ystep
After each server x and y coordinates will be rised by this values. Unless you wan't your servers to be aligned diagonally one of these variables should be 0.
$templates_default, $templates_active and $templates_down
Templates for normal, active (the server you are currently playing on) and down (offline) servers. active and down templates are optional, if you don't set them the default template will be used.
Each one of these variables is array of templates. Every template looks like this:
array ('x' => 0,
'y' => 0,
'color' => '255 255 255',
'font' => './tf2secondary.ttf',
'size' => 12,
'text' => '#name#')
You have to set six variables:
$servers Array of servers which should be displayed. Each server looks like this:
array ('name' => 'Server 1 NL All maps',
'ip' => '85.17.60.96',
'port' => 27025,
'pass' => '')
You have to set four variables:
5. Testing
Open motdpic.php in your browser and check the output. You can also try the active server template by going to motdpic.php?server=ip:port (for example, motdpic.php?server=85.17.60.96:27035). Tweak the settings until you are happy with the result.
Note: While testing, set $cachelifetime to 0 so you will always see tha last version without waiting for cache expiration.
For example, here is our image with live stats:
6. Putting it live
In the zip archive you'll also find file motd.php. It's slightly modified HTML&CSS from out chalkboard MOTD guide. It contains the image on the chalkboard background.
So all you have to do is open the motd.txt in your server's tf directory and put link to your motd.php there.
For example, this is how motd.txt on our server #2 looks loke:
http://content.specialattack.net/motd2/motd.php?server=85.17.60.96:27035
7. Conclusion
Ta-Daa! You have cool MOTD with live stats. Please do not copy this guide, but link to our site, when recommending this guide to others.
If you have any ideas for improvements, questions or problems use the comments.
Comments
Server Connection Issues
21. February 2009 - 14:47 — AnonymousHey there,
I can get all the font/layout stuff for the most part (colours don't seem to want to work), but no matter what I put in for server ip/port/password, I cannot get the a response from the server. It always says server timed out. Here's my page:
http://www.agedinoakcasks.com/motd/motdpic.php
Any ideas? I've tried the ips/ports/rcon passes of 4 or 5 different servers.
Setup Difficulty
16. December 2008 - 20:48 — Vegas#timeleft# not working.
24. October 2008 - 23:00 — Anonymousme again^^
1. September 2008 - 12:23 — Anonymouscannot get timeleft to work
1. September 2008 - 3:04 — AnonymousStruggling to get it to
28. August 2008 - 17:21 — AnonymousDo you guys have a blank of
20. August 2008 - 23:44 — AnonymousErrors on LInes 124 and 137/138
1. August 2008 - 20:36 — Anonymoustry to enter absolute path to
2. August 2008 - 16:30 — lacopthanks but ... n°2
11. July 2008 - 19:28 — Anonymousthat array (...) is just one
12. July 2008 - 9:57 — lacopthanks but ...
11. July 2008 - 12:23 — Anonymouslooks like you have a typo in
11. July 2008 - 12:51 — lacopMany thanks!
1. July 2008 - 16:55 — AnonymousMe again.
7. July 2008 - 16:53 — Anonymousi cant get timeleft to work
1. September 2008 - 3:03 — Anonymousare u using SourceMod? what
7. July 2008 - 19:18 — lacopYeah, we're using SM.
9. July 2008 - 3:44 — Anonymous