# TrackMania Nations - TMN & XASECO quick start guide
Information on setting up a dedicated server and the XASECO system for TrackMania Nations, a racing game by Nadeo
Author: Frans P. de Vries
Keywords: TrackMania, Nations, Original, Sunrise, racing, games, XASECO, ASECO, RASP, Jfreu, plugins, records, jukebox, Nadeo

### Quick Start Guide:

This is step-by-step guide to setting up a classic TrackMania Nations (TMN) dedicated server with XASECO for those lost in or confused by the available readme's and tutorials, and those just too lazy to read them. ;-)

It's written for Linux but should largely apply to Windows too, and your system needs to have a working MySQL 4.x or 5.x and PHP 5.x setup. To manage the database, enter the MySQL commands in the mysql command prompt, PhpMyAdmin or another tool of your choice. You need to run the TMN server and XASECO on the same machine, running them on separate machines is beyond the scope of this guide.

First, the dedicated server:

1. Ideally, the TMN server and XASECO run under a user account rather than root, so create a user e.g. "tmn" with home directory "/home/tmn".
2. Login as (or switch to) user "tmn" so that all files created down the road receive the correct ownership and permissions.
3. Download and unzip the final TMN server (TmDedicatedServer_2006-05-30.zip) into this home directory, the default path will be TmDedicatedServer/.
4. Edit TmDedicatedServer/dedicated.cfg:
   1. In the <authorization_levels> section, change all three passwords, but do not change the names (SuperAdmin, Admin, User).
   2. In the <masterserver_account> section, enter a new server <login> (different from your player login) with its own <password> (again different) and an appropriate and valid three-letter <nation>. If you're not sure your chosen login is new, use your TMN client to test it first, in both cases the account will be registered automatically with the masterserver.
   3. In the <server_options> section, give your server a <name> and configure the other options to your liking.
   4. In the <system_config> section, set <connection_type> to a value closest to your connection's speed (see the server readme for correct values), and remember the three port numbers (default: 2350 for the server, 3450 for P2P and 5000 for XMLRPC; these can be changed to other free port numbers, but it's recommended to keep the defaults at least until your server comes online successfully).
5. Edit the default match settings file TmDedicatedServer/GameData/Tracks/MatchSettings/Internet/AdvancedTraining.txt to your liking (again, see the server readme for details).
6. On your firewall/router, open the server port 2350 and the P2P port 3450 for both UDP and TCP traffic, but not the XMLRPC port 5000. For the Dedimania system in XASECO port 8002 needs to be open as well. For more information on this, PortForward.com may be useful.
7. Start the server:
   `cd ~/TmDedicatedServer/`
   `./RunTrackmaniaNations.sh` (or `RunTrackmaniaNations.bat`)
   You should see output like the following:

       Starting TmNationsESWC v2006-05-30...
       Unable to open '/home/tmn/TmDedicatedServer/Default.SystemConfig.GbxInitializing...
       Configuration file : dedicated.cfg
       Loading system configuration...
       ...system configuration loaded
       Loading cache...
       ...OK
       Listening for xml-rpc commands on port 5000.
       Trackmania server daemon started with pid=28936 (parent=28935).

   If you get a Segmentation Fault here, the server cannot create files/directories due to ownership/permission problems (perhaps you forgot step 2?).
8. The first time the server starts, it creates that Default.SystemConfig.Gbx file, as well as the blacklist.txt and guestlist.txt files and a number of directories like Logs/, GameData/Cache/, GameData/Profiles/, GameData/Scores/, GameData/Tracks/Campaigns/, GameData/Tracks/Replays/, GameData/Tracks/Challenges/Downloaded/ and GameData/Tracks/Challenges/My Challenges/. The files in the Logs/ directory are useful to monitor your server's activity.
9. Start your TMN client and check in the Internet server browser that the server is running in your Nation with your chosen server name and the Nadeo Advanced tracks.
10. Join your server, and have a friend join from elsewhere on the Internet, to verify that the server is accessible.
11. Ignore the private network warning that is always logged in ConsoleLog.*.txt.
12. To start & stop your TMN server on Linux more easily, you can use this start-up script.
13. Collect your own tracks in GameData/Tracks/Challenges/My Challenges/, copy and edit a new match settings file in GameData/Tracks/MatchSettings/Internet/ that lists those tracks, use that file in RunTrackmaniaNations.sh (or RunTrackmaniaNations.bat), and restart your server. It should now be running your track selection. Congratulations. :-)

Secondly, the XASECO system:

1. Create the XASECO database in MySQL (default "aseco" but any other name is okay too):
   `CREATE DATABASE aseco;`
   Also create a separate user (e.g. "tmn") in MySQL with a password, and grant this user all rights to the "aseco" database. The basic MySQL commands are:
   `CREATE USER 'tmn'@'localhost';`
   `SET PASSWORD FOR 'tmn'@'localhost' = password('password');`
   `GRANT all ON aseco.* TO 'tmn'@'localhost';`
2. Login as (or switch to) user "tmn" so that all files created down the road receive the correct ownership and permissions.
3. Download and unzip XASECO (latest version) into the "/home/tmn/" directory too, the default path will be xaseco/ so that future releases can be unpacked into the same directory tree.
   In the zip file, all *.XML and config files are located inside the newinstall/ directory. Go into the newinstall/ directory and move all *.XML files into the main directory (next to aseco.php), and move all *.PHP files into the includes/ directory.
   Also, move Aseco.sh (on Linux) or Aseco.bat (on Windows) into the main directory and adjust it to your situation if necessary.
4. Setting up the database tables in MySQL is done automatically the first time XASECO runs, but if you prefer you can do it manually in advance:
   `USE aseco;`
   `SOURCE /home/tmn/xaseco/localdb/aseco.sql;`
   `SOURCE /home/tmn/xaseco/localdb/rasp.sql;`
   `SOURCE /home/tmn/xaseco/localdb/extra.sql;`
5. Edit xaseco/localdatabase.xml:
   1. Replace YOUR_MYSQL_LOGIN with the MySQL user you created above, e.g. tmn.
   2. Replace YOUR_MYSQL_PASSWORD with the MySQL password you set above.
   3. Use the same database name as you created above, e.g. aseco.
   4. localhost is your own machine, so the server option is okay.
6. Edit xaseco/config.xml:
   1. In the <masteradmins> section, uncomment and replace YOUR_MASTERADMIN_LOGIN with your player login, and add further logins for other players you want to grant all XASECO admin rights.
   2. In the <tmserver> section, replace YOUR_SUPERADMIN_PASSWORD with the password you chose for SuperAdmin in dedicated.cfg (TMN step 4a above) but do not change the SuperAdmin login itself.
   3. The <port> field should contain the same XMLRPC port number you chose in dedicated.cfg (TMN step 4d above), default 5000.
   4. IP 127.0.0.1 is your own machine again, so that option is okay too.
7. Edit xaseco/adminops.xml:
   1. In the <admins> section, uncomment and replace YOUR_ADMIN_LOGIN with an admin's login, and add further logins for other players you want to grant partial XASECO admin rights. Or leave the <tmlogin> entry commented out if there are none.
   2. In the <operators> section, uncomment and replace YOUR_OPERATOR_LOGIN with an operator's login, and add further logins for other players you want to grant XASECO operator rights. Or leave the <tmlogin> entry commented out if there are none.
8. Edit xaseco/dedimania.xml if you want to use the Dedimania world records system:
   1. In the <masterserver_account> section, replace YOUR_SERVER_LOGIN and YOUR_SERVER_PASSWORD with the <login> and <password> values from your dedicated.cfg file.
   2. Also, replace YOUR_SERVER_NATION with the <nation> value.
   3. Instead of the password you can also enter the community code for your server which can be obtained by using the server login/password on the official site for your game (TMO/TMS/TMN).
   4. To disable Dedimania support, remove or comment out the chat.dedimania.php and plugin.dedimania.php entries in plugins.xml.
9. Start the XASECO system:
   `cd ~/xaseco/`
   `./Aseco.sh` (or `Aseco.bat`)
   You won't see output, but logfile.txt should contain something like the following:

       [XAseco] PHP Version is 5.3.x on Linux
       [XAseco] Load settings [config.xml]
       [XAseco] Load admin/ops lists [adminops.xml]
       [XAseco] Load banned IPs list [bannedips.xml]
       [XAseco] Load plugins list [plugins.xml]
       [XAseco] Load plugin [plugin.localdatabase.php]
       [XAseco] Load plugin [plugin.rounds.php]
       [...snip plugins...]
       [XAseco] Load plugin [jfreu.plugin.php]
       [XAseco] Load plugin [mistral.idlekick.php]
       [XAseco] Try to connect to TM dedicated server on 127.0.0.1:5000 timeout 180s
       [XAseco] Try to authenticate with username 'SuperAdmin' and password 'PASSWORD'
       [XAseco] Connection established successfully!
       [Local DB] Load settings file
       [Local DB] Try to connect to MySQL server on 'localhost' with database 'aseco'
       [Local DB] MySQL Server Version is 5.1.56-log
       [RASP] Cleaning up unused data
       *-*-*-*-*-* RASP is running! *-*-*-*-*-*
       |...Loading Settings
       |...Loaded!
       |...Checking database structure
       |...Structure OK!
       |...Calculating ranks
       |...Done!
       [12/xx,xx:11:17] ************* (Dedimania) *************
       [12/xx,xx:11:17] * Dataserver connection on Dedimania ...
       [12/xx,xx:11:17] * Try connection on http://dedimania.net:8002/Dedimania ...
       [12/xx,xx:11:18] Webaccess (dedimania.net:80): send: deflate, receive: gzip
       [12/xx,xx:11:18] * Connection and status ok! :)
       [12/xx,xx:11:18] * NEWS (Dedimania, 08/05): news
       [12/xx,xx:11:18] ------------- (Dedimania) -------------
       [12/xx,xx:11:18] Load auto timelimit config [autotime.xml]
       ###############################################################################
         XASECO v1.1x running on 127.0.0.1:5000
         Name   : YOUR SERVER NAME
         Game   : TmNationsESWC - TimeAttack
         Version: 0.1.7.4 / 2006-05-30
         Authors: Florian Schnell & Assembler Maniac
         Re-Authored: Xymph
       ###############################################################################
       Begin Race
       [12/xx,xx:11:18] track changed [none] >> [Pro - 38~74~75~89~93]
       [12/xx,xx:11:18] currently no record on Pro - 38~74~75~89~93

   If you get an RPC Permission Error here, there is an XMLRPC port mismatch or the dedicated server isn't running (anymore).
10. To start & stop your XASECO on Linux more easily, you can use this start-up script.
11. Edit the configuration options to your liking, and restart XASECO. It should now be ready to manage tracks, receive players, and record... er... records. Congratulations. :-)

Finally, to run another server on the same machine:

1. Basically follow the same steps above, but use a second user account (e.g. "tmn2"), another new server login/password in dedicated.cfg, a separate server name, a second set of ports (e.g. 2351, 3451 and 5001), a new database (e.g. "aseco2"), optionally a second MySQL account (e.g. "tmn2"), and the corresponding updates in localdatabase.xml and config.xml.
2. Don't use symbolic links in the GameData/ directory tree (e.g. to symlink the tracks from the first server to the second one), as the TMN server will crash without an error message.

And for the last time, read the readme's and tutorials completely for a more thorough understanding of the entire setup.