Outgun / Documentation / Web interface

Web interface

Outgun 1.0 server can be set to send information to a web script. That allows you to show some details of your server in a web site.

Contents

Configuring the game

Write the script specific commands in the gamemod. The web_server command tells the hostname or IP address of the web server. You can have as many of those as you want. Outgun tries to connect to them in order until success. The script location in the server is also needed.

If you want to use the basic HTTP authentication in the submit script, also set a user name and password for that. The refresh interval is how often the game sends information to the script.

; List of the addresses for the web server, can be names or IPs.
web_server hostname.example
web_server 127.0.0.1

; Script path in the server.
web_script /example/submit.php

; Authentication if any (user:password).
web_auth user:password

; Refresh interval, in minutes.
web_refresh 2

; The web page of the server
server_website http://example.org/foo/outgun.php

The URL is used in a link in the web server list and in the server info message in the game.

Configuring the web server

You should make some kind of authentication in the web server to allow connections to the script only from your Outgun server. HTTP authentication is probably the easiest method for this. Outgun sends the user name and password in the correct header as Base64 encoded. If you can’t or don’t like to do HTTP authentication, you can check the name and password in your script.

If your Outgun server has a static IP address, you can make your script to only allow connections from that IP address. That can be made by the HTTP server or in the script. See Authentication in Apache 2.0.

Script

The web script can be PHP, Perl, C++, C or anything as long as the web server supports it. The data is sent by POST method and as URL encoded. The script can do whatever you make it to do. You probably want it to save the data to a file and have another script to read and show some information to users. It is useful to respond something to the game server to see if the posting was successful. Outgun saves the response to log/web.log file.

Parameters

Outgun server sends following parameters to the web script.

Parameters sent on every update
nameserver name
ipserver IP address
portserver port
dedicatedsent if the server is dedicated
playersplayers on the server
max_playersmaximum number of players
versiongame version
uptimeserver uptime in seconds
maptitle of the current map
mapfilefile name of the current map without .txt extension
playerlistlist of the players, newline separated
Parameters sent only at the first update
maplistlist of the maps, newline separated
Parameters sent when the server is shutting down
quitserver shutdown message

Player list

There is one player on a line in the player list. On the line are the player’s name team ID (0 for red and 1 for blue) and ping (in milliseconds). These are separated by a tab character.

Player A<TAB>0<TAB>191
Player B<TAB>0<TAB>77
Player C<TAB>1<TAB>125
Player D<TAB>1<TAB>63

Example

I have made a script system in PHP. I have three PHP files. submit.php saves incoming parameters to a outgun.txt file. huntta-server.php shows the saved information to users. Both files include server.php which contains the Server and Player classes.

Put index.php to any web directory you want to. Make there a directory called server. Put submit.php and server.php under the server directory. Give server/outgun.txt proper rights (group write), so the script can write in it.

Make HTTP authentication to server directory to prevent anyone and his dog submitting information. Write the same user name and password you used in authentication to website.txt in your Outgun config directory.

Now anyone can see the server information from huntta-server.php. Only your Outgun server can submit the information to server/submit.php.

If you want to get the map pictures work, make a directory maps and put the map pictures there. Notice that in my example the map pictures are named as mapname.png.

See the working example.


Updated 2006-02-13 – Jani Rivinoja