Mxserver Tutorial

Post anything about MX Simulator here. Please. I'm begging you.
User avatar
yzmxer608
Posts: 15082
Joined: Mon Dec 29, 2008 4:30 am
Team: Race Tech/SD
Location: Wisconsin, U.S.A

Mxserver Tutorial

Postby yzmxer608 » Tue Feb 09, 2010 4:09 am

I think this tutorial has been needed for a while. I'll try to cover it as best as I can.

Creating the Server:
First you will have to download the server app, you can get it here. Once you have it downloaded unzip it to a location of your choice. Now read the readme.txt, it will most likely answer a lot of your questions before reading the rest of this. It covers pretty much everything about the app, but I'll try to focus on getting a basic server up and running. There is a template that includes a batch file to run the server in the server download.

I usually make the args file first, it's what tells the server all of the information it needs to run properly. I find it easier to organize using the args file instead of putting everything in the command line. Using the readme as a guideline, here is what you want to put in the args file, I will only add the basic parameters, if you want to use the more advanced parameters they are explained in the readme:

  • --port xxxx
    • Enter the port you want to use. Most people use 19800, you don't have to use it, but I'd reccomend using it just because it's easier to remember.
  • --max-clients x
    • Replace X with the max amount of people you want to have in your server. It's best to cap it at what your network can handle, to find that out refer to this table jlv made, when calculating use your upload speed rather than download. If you don't know what your upload speed is, do this test here. Just remember, it gives your speed in megabits per second, while this chart is in bytes. To convert megabits to bytes use the calculator on this site. Just enter the appropriate number and from the drop-down box choose megabits and click calculate. Use the number next to bytes for this chart:

      In bytes per second, here's an approximation of how much bandwidth you need for a given number of players:
    • 1 3808
    • 2 10624
    • 3 20448
    • 4 33280
    • 5 49120
    • 6 67968
    • 7 89824
    • 8 114688
    • 9 142560
    • 10 173440
    • 11 207328
    • 12 244224
    • 13 284128
    • 14 327040
    • 15 372960
    • 16 421888
    • 17 473824
    • 18 528768
    • 19 586720
    • 20 647680
    • 21 711648
    • 22 778624
    • 23 848608
    • 24 921600
    • 25 997600
    • 26 1076608
    • 27 1158624
    • 28 1243648
    • 29 1331680
    • 30 1422720
    • 31 1516768
    • 32 1613824
    • 33 1713888
    • 34 1816960
    • 35 1923040
    • 36 2032128
    • 37 2144224
    • 38 2259328
    • 39 2377440
    • 40 2498560
  • --password xxx
    • Replace XXX with the password you want to use for the server. You will be required to use a password to use the administrator privileges of the server.
    • While we are at it, create another shortcut for the mx.exe (go to where you installed the game and find mx.exe, right click it and go down to "Create shortcut"). Once the shortcut is created, right click it and go down to Properties. In the new window, at the Target box, add a space at the end of ...\mx.exe" and add --password xxx. Again, replace xxx with the password you want to use. You will use this shortcut just for connecting to your server. You can do this to your existing shortcut, but if you try and connect to anyone else's server you will not be able to join since the passwords won't match.
  • --greeting "xxx"
    • Here you can enter the greeting people will see when they enter the server.
  • --ban-file xxx
    • This is what specifies the name of the file ban info will be stored in. Just use bans.txt.
  • --results-file xxx
    • Same as with the ban file, results.txt is common.
  • --track-interval xxx
    • This is what tells the server when it's time to switch to the next track, the parameter is in minutes (a track interval of 15 would be 15 minutes until the track will automatically switch, if 15 minutes is passed during a race the track will change for the next race).
  • --laps xxx
    • Sets the number of laps for each race.
  • Next major thing is to get the trackinfo files for the tracks you want to have on the server. To get them, go in game and start a race on whatever track you want. While at the track, in the chat window (press 't') type /savetrackinfo. The file will be saved to your personal folder, note that you will have to do this individually for each track you want.

    Once you have all of the trackinfo files you want, it's time to actually add them to the server. There is a folder in the mxserver directory named trackinfo, put all of your trackinfo files into it. Now we have to go back to the args file, you will now have to add a line of text with the name of each trackinfo file. Before the name of each trackinfo file, just add trackinfo/... (this tells the server to look in the trackinfo folder for the trackinfo files). An example for what you would use is:
    • trackinfo/alcrest.trackinfo
    • trackinfo/locust.trackinfo
    • trackinfo/x1b.trackinfo
    • trackinfo/overhill.trackinfo
    Note, if the trackfolder/trackinfo file has spaces in it, put a set of quotes around it in the serverargs. For example:
    • trackinfo/"Oh Sorry.trackinfo"

Running the Server:
    Now everything you need for the server to run is there. To get the server running I create a batch file, it's easy to use (once made). Note, jlv has released a batch file to run the server in the lastest server download, which is linked at the top of this post.

  • Right click somewhere (desktop is fine) and go to New, then choose text file from the list. You can name it anything you want, startserver is descriptive enough. Open the txt file and use this as a guideline:

    Code: Select all

    cd Directory Of mxserver
    mxserver.exe --args-file serverargs.txt

    • So for example, if you had your mxserver folder on your desktop, you would have (for Win7/Vista):

    Code: Select all

    cd C:\Users\YourName\Desktop\mxserver
    mxserver.exe --args-file serverargs.txt
  • The 'cd' just changes the working directory of the command prompt, so it "operates" out of where you tell it to (in our case the mxserver folder). The next line starts the mxserver.exe and passes --args-file serverargs.txt as a parameter, telling the server to use the args file you created. When you are done save the txt file, but, after you saved it right click the file and go to Rename, you can keep the actual name the same but delete the .txt and replace it with .bat. (you can skip this if you use Notepad++ and just save it as a .bat file right away). You will get a warning about changing the file type, just click Ok.

    Now, all you should have to do is double click your new batch file and your server should start up. If the command prompt doesn't stay open something has gone wrong. First thing to check is if there are any typos in your args file, if that doesn't work try right clicking the batch file and go to Run as administrator.

Connecting To the Server:
Now that you have your server up and running it's time to do some racing!

  • Have your server running, then use the second mx.exe shortcut you created (the one you added your password to) to start the game. Go to the Multiplayer menu and type '127.0.0.1' (without the quotes). This is what you have to use to enter YOUR own server, only you use that.
  • Now for other people to join, they will have to use your ip. To find what your ip is you can go to a site like What Is My IP Address?, tell that number to whoever is going to join your server so they can use it. In game they will enter exactly what the site shows you (no spaces). You can add :port to the end of it if you want (replace port with the port number you used in your args file).

Connecting to a Server on the Same Connection:
If you have a second computer on the same internet connection (wireless network) this is how you connect to it.

  • On the computer running the server, click Start, go to All Programs, Accessories, then Command Prompt.
  • When it opens type ipconfig, and write down what it says nest to IPv4 Address.
  • On the second computer, use what you just wrote down as the ip to connect to the server, you might also need to add the port you used at the end, like a regular ip.

Troubleshooting Connecting:
If people can't join your server there could be a couple things wrong.

  • The first is you have a firewall that is blocking them. You will have to let mx.exe be an exception to your firewall (every firewall is different, if you don't know how just search the internet).
  • A second possibility could be that you have to forward your router's ports for the port you are using for your server. To do this go to Port Forward. This website will NOT forward the ports for you, it will just tell you steps to take to do it. Find your router brand and model in the list, if you don't know the model take a look on your router and you should find a model number/name. That will take you to a page with the names of a bunch of programs, since the mxserver.exe is not listed just click some random program, we just need the directions for your router model.
  • Follow the directions until you get to the part where you enter the port forward parameters. When you get to that point select the UDP protocol and change it's port from 19800 to 19800 (or whatever port number you used in your args file). It doesn't matter what name you choose, I suggest mxserver so you will know which one it is later if you ever need to edit it. After that save the changes and you should be Ok.

Uploading Results to Stats Page:
This will tell you how to have the results from races uploaded to the main stats site.

  • First download curl:
    Curl: - Download

    Then just place it in your server folder with everything else.
  • Next make another batch file, name it anything you want. In it put:

    Code: Select all

    curl -s -F "name=your ip " -F "password=a password" -F "results=<results.txt" http://mxsimulator.com/uploadresults.php

  • Keep all of the double quotes, but replace 'yourip' with your ip address (http://ipchicken.com), make a password (you'll need to keep using it, just don't change it).
  • Now open your args file again and add:

    Code: Select all

    --results-cmd Results_Upload.bat

  • Rename 'Results_Upload.bat' to whatever you named your batch file.

    That's all you have to do, start you server and make sure it runs.

Externally Sending Commands to the Server
It's possible to send commands to your server without actually having the game client open. I have found two ways to do this, one using a separate program, and another using python scripts (for Windows, if using Linux the bash command is in the readme by jlv).

  • First we need to add a new parameter to the server args (this has to be done no matter which method you use):

    --xcmd-password 123

    Put whatever you'd like after the parameter to use as your password when sending commands (in this case the password is 123) NO SPACES!!!
  • Method 1: Python Scripts
    • Make sure you have Python installed. Next create a new text document and paste the following in it. Name it whatever you'd like, but make sure to change the extension to .py.

      Code: Select all

      import socket
       
      UDP_IP = "127.0.0.1"
      UDP_PORT = xxxxx
      MESSAGE = "x123restart"
       
      print "UDP target IP:", UDP_IP
      print "UDP target port:", UDP_PORT
      print "message:", MESSAGE
       
      sock = socket.socket(socket.AF_INET, socket.SOCK_DGRAM) #internet # UDP
      sock.sendto(MESSAGE, (UDP_IP, UDP_PORT))

    • Leave the UDP_IP = "127.0.0.1" alone.
    • Change the UDP_PORT = xxxxx to what you have your port set for the server in the args file.
    • The MESSAGE is the important part, it uses this format:

      "<x><password><command>"

      The 'x' MUST always be there, next put the password you set in the args file (in my case it's 123), then the command you want (i.e. shutdown, restart etc.) DON'T ADD SPACES HERE!!!

    • Now put this .py file in the install directory of Python. Now all you have to do it start your server like how you always would, then whenever you want to send the command execute the .py file you made- the command will be sent without you being in game!
    • If you want to send different commands without editing the python script every time, make a copy of the script, rename it, and just change the MESSAGE line to whatever other command you want. The downfall of this is you have to use multiple scripts for separate commands. Method 2 will allow you to only run one program for all commands.
  • Method 1 Improved
    • This is an improved version of the above script, created by Wahlamt. He explains what it does in the post below, basically the script isn't tied to a single command, as it asks you what command you want. The last line I added to what he already had, what it does is calls the script again so it appears that the window stays open. This allows you to have the ability to send multiple commands without having to open the script manually again.

      Replace "sendcommands.py" with whatever you named the script.
      Wahlamt wrote:

      Code: Select all

      #/usr/bin/python

      import socket

      UDP_IP = "127.0.0.1"
      UDP_PORT = 19800
      MESSAGE = "x123"

      command = raw_input('Enter the command you wish to execute: ')

      MESSAGE += command

      print "UDP target IP:", UDP_IP
      print "UDP target port:", UDP_PORT
      print "message:", MESSAGE

      sock = socket.socket(socket.AF_INET, socket.SOCK_DGRAM) #internet # UDP
      sock.sendto(MESSAGE, (UDP_IP, UDP_PORT))

      execfile("sendcommands.py")

      The modification here is that it cuts out after the "xPASSWORD" part and prompts the user for a command. The "server," part of the command is not needed as you'd type it in a server, if anyone wonders. When it prompts you, let's say you want to set the track 5, then type "settrack 5" without the quotation marks. If you'd like to broadcast a message, then type "broadcast This is a cool broadcast message for you!". This is my first time trying to do something useful with python so there might be better ways to do this than I was able to do, also maybe someone has made it before. Yet I though I could share it :)

  • Method 2: Packet Sender
    The second method uses a program called Packet Sender. You provide almost the same info as the python method, but this will allow you to have however many commands you want in a list, WITHOUT having to create multiple scripts like you would with python.
    • First download and install the program, then run it. The Packets tab is where we will be working.
    • In the Name box you can put anything (would make sense to name it the command the packet will be sending i.e. "Shutdown Server").
    • The ASCII box is the exact same as the MESSAGE line for the python script (read above).
    • Don't worry about the HEX box.
    • In the IP address box put 127.0.0.1.
    • In the port box put the port you have listed in your args file for your server.
    • Change the drop-down box to UDP.
    • Start your server up and click the Test button, this will send the command immediately. If it works correctly click the Save button, this will put the Packet in the list below for future use.
    • Repeat this for any other command you want to send, then all you have to do is choose it from the list when you want to use it :).

      Example packet:
      Image

Other Notes:
  • If you change the name of your computer ([here's a tutorial on how]) you will have to forward your ports again. First check to see if you can just change which computer on the network can host applications through the router. Then you won't have to forward the ports again, all you will have to do is change the hosted computer from your old "name" to the new one.

I hope this tutorial has helped some people. A lot of what was stated is in the readme file, I just wanted to make it more public so people can discuss or find out things they skipped over before. Feel free to leave comments about what can be added/changed.

Thanks to jlv for the bandwith list and explanation on the stats page, thanks to DJ for explanation on the stats page, and thanks to Wheels for helping with the Packet Sender program!
Last edited by yzmxer608 on Sat Feb 03, 2018 4:11 am, edited 18 times in total.
TeamHavocRacing wrote:If I had a nickel for every time someone asked for this, I would have a whole shitload of nickels.

JiMMy
Posts: 34
Joined: Wed Oct 07, 2009 8:49 pm

Re: Mxserver Tutorial

Postby JiMMy » Wed Feb 10, 2010 4:11 pm

good stuff, might help some new users.
btw, you can also use a batchfile to start the server, so you dont have to type "mxserver --args-file serverargs.txt" everytime in the cmd console.

http://www.mediafire.com/download.php?cz2y4fjymfy
Image

User avatar
yzmxer608
Posts: 15082
Joined: Mon Dec 29, 2008 4:30 am
Team: Race Tech/SD
Location: Wisconsin, U.S.A

Re: Mxserver Tutorial

Postby yzmxer608 » Thu Feb 11, 2010 3:41 am

That batch file in the tutorial does :).
TeamHavocRacing wrote:If I had a nickel for every time someone asked for this, I would have a whole shitload of nickels.

User avatar
Shadow
Posts: 2751
Joined: Sun Dec 02, 2007 5:10 pm
Team: FSK
Location: Finland

Re: Mxserver Tutorial

Postby Shadow » Fri Feb 19, 2010 9:15 am

I suck at this bit/byte stuff, how many riders could be handled with a 100/100 Mbit connection?
Image
Those who possess strength have also known adversity.

User avatar
DJ99X
Posts: 15465
Joined: Tue Jan 15, 2008 11:36 am
Team: El Chupamobra
Location: Upper Shit Creek, Sans Paddlington

Re: Mxserver Tutorial

Postby DJ99X » Fri Feb 19, 2010 9:47 am

Pretty sure there are 8 bits in a byte, so 100,000,000 bits/a = 12,500,000 bytes/a = 12.5mb/s.

So theoretically, you could handle any amount

User avatar
Shadow
Posts: 2751
Joined: Sun Dec 02, 2007 5:10 pm
Team: FSK
Location: Finland

Re: Mxserver Tutorial

Postby Shadow » Fri Feb 19, 2010 10:46 am

Cool, now on to find if the uni has some policy against hosting a server! :D
Image
Those who possess strength have also known adversity.

User avatar
yzmxer608
Posts: 15082
Joined: Mon Dec 29, 2008 4:30 am
Team: Race Tech/SD
Location: Wisconsin, U.S.A

Re: Mxserver Tutorial

Postby yzmxer608 » Sat Feb 20, 2010 4:37 am

Seems like all college connections are really fast :shock:.
TeamHavocRacing wrote:If I had a nickel for every time someone asked for this, I would have a whole shitload of nickels.

User avatar
Shadow
Posts: 2751
Joined: Sun Dec 02, 2007 5:10 pm
Team: FSK
Location: Finland

Re: Mxserver Tutorial

Postby Shadow » Sat Feb 20, 2010 1:44 pm

Haha, mine's actually on the slower end. Most student apartments have 1Gbit connections. :lol:

Meh.. Figured it wouldn't be allowed to host a server. :x
Image
Those who possess strength have also known adversity.

User avatar
yzmxer608
Posts: 15082
Joined: Mon Dec 29, 2008 4:30 am
Team: Race Tech/SD
Location: Wisconsin, U.S.A

Re: Mxserver Tutorial

Postby yzmxer608 » Sat Feb 20, 2010 3:40 pm

Did you ask them or does it just not run?
TeamHavocRacing wrote:If I had a nickel for every time someone asked for this, I would have a whole shitload of nickels.

User avatar
Shadow
Posts: 2751
Joined: Sun Dec 02, 2007 5:10 pm
Team: FSK
Location: Finland

Re: Mxserver Tutorial

Postby Shadow » Sat Feb 20, 2010 3:58 pm

Asked. If the server would've been set up just for people inside the university's network, no problem then but it's not allowed for outside connections.
Image
Those who possess strength have also known adversity.

User avatar
yzmxer608
Posts: 15082
Joined: Mon Dec 29, 2008 4:30 am
Team: Race Tech/SD
Location: Wisconsin, U.S.A

Re: Mxserver Tutorial

Postby yzmxer608 » Sat Feb 20, 2010 4:41 pm

Oh, that sucks :(. Would've been some good times.
TeamHavocRacing wrote:If I had a nickel for every time someone asked for this, I would have a whole shitload of nickels.

User avatar
magnusson
Posts: 2618
Joined: Fri Jan 15, 2010 12:38 am
Team: Wannabe
Contact:

Re: Mxserver Tutorial

Postby magnusson » Wed Mar 03, 2010 12:03 am

im sorry but i think i'm blind i cant se where to put all these commands? :oops: do i make a txt file or ?? :roll:
vurbmoto wrote: - Kevin Windham is still a BOSS

My Release's on PureMXS

User avatar
Jones221
Posts: 5095
Joined: Wed Mar 04, 2009 4:11 am
Team: Barry
Location: California

Re: Mxserver Tutorial

Postby Jones221 » Wed Mar 03, 2010 12:04 am

Yes you do.

User avatar
yzmxer608
Posts: 15082
Joined: Mon Dec 29, 2008 4:30 am
Team: Race Tech/SD
Location: Wisconsin, U.S.A

Re: Mxserver Tutorial

Postby yzmxer608 » Sat May 15, 2010 6:11 pm

One thing I found out yesterday, if you get a new computer and "name" it different (go into the control panel, then go to the system part, you should be able to find the computer "name") from your other one, and you have forwarded ports before, you will have to forward the ports again for the new computer (or just change the computer that will host applications through the firewall (should be a list somewhere in your router settings). Not sure if all routers have this, but the one I have does, had to do it to get my server working.
TeamHavocRacing wrote:If I had a nickel for every time someone asked for this, I would have a whole shitload of nickels.

ddmx
Posts: 5265
Joined: Sun Apr 20, 2008 3:36 pm
Team: Epikmx.com
Location: Midland MI
Contact:

Re: Mxserver Tutorial

Postby ddmx » Sat May 15, 2010 6:34 pm

Does the bandwidth apply equally to upload and download speed from your isp? At my new place, time warner supplies a 5mb download, and .5mb upload speed. Would this be sufficient?
The MXS 1%


Return to “General Discussion”

Who is online

Users browsing this forum: No registered users and 8 guests