How to set up an xRC game server on Ubuntu v20+
10 min read
What is xRC?
You're probably familiar with what it is if you're here, but for those who are unaware: xRC is a simulator for FIRST Robotics Competition, FIRST Tech Challenge, and Vex Robotics Competition games.
To play multiplayer remotely, you must use one of the servers set up by others (of which there are not many) or you have to set up your own server, which is what we're gonna do today. xRC does have its guide for AWS, but it's very specific to AWS and doesn't provide much background for other cloud providers.
This is not the only way to play multiplayer. If you're on the same local network with the people you are going to play xRC with, you can do multiplayer locally. You can also configure your own computer to host the server for your remote friends with some port forwarding trickery. This guide just covers setting up a cloud server, which is the more secure and reliable option.
Setting up a basic Ubuntu Server
I will assume that you have some basic Linux/Ubuntu knowledge and have a server set up. You should be logged in as the root user via an SSH key.
Based on the info from the xRC AWS Guide and my own experience:
For a basic game, you should have at least 1 vCPU and 1 GB of RAM. Ubuntu and xRC run pretty nicely on these things.
Let's create a custom admin user for xRC. For this, I will call it
You'll be asked a few questions, the only important one being about your password. I set mine to
xrcfor simplicity, because if your root user is configured with ssh, that's what you will always use to log in, not a password.
Now we have to grant our
xrcuser sudo priveledges:
usermod -aG sudo xrc
To make it easier to log in directly as
xrc, we're going to copy the ssh public key from the root user to
rsync --archive --chown=xrc:xrc ~/.ssh /home/xrc
Later in the guide, we're going to need
ufw, Ubuntu's built in uncomplicated firewall. Run the following commands:
# Allow ssh connections sudo ufw allow ssh # Enable the firewall sudo ufw enable
We're all set up now, so for the next steps you need to switch to the xrc user. You can either log out and log back in with your ssh private key and the address
xrc@<your server ip>or
Installing and Running xRC
Great! We've got ourselves a server. Now to make this thing a game server.
Whenever installing anything, I always recommend a making a directory for it. First, make sure you're in the home directory for the user
xrc, which can be done by running
cd /home/xrc; this will move you to the right directory no matter where you are. Now do
Let's get xRC going. I tried to find a way, but I couldn't figure out how to directly download the file onto the server, so it's SFTP time. Head over to https://xrcsimulator.org/downloads/ and download Linux Server x64 (zip) (for servers without graphics cards)
Next, use your tool of choice to transfer the downloaded zip file to
/home/xrc/xrc-server. I used WinSCP, but Filezilla or any command utility like rsync or sftp would work.
Log back into your server and get into the aforementioned directory. Run the following commands:
# Download the unzip utility sudo apt install unzip # Find the file that you need to unzip, usually like xRC_Linux_Server_v9.0d.zip unzip <your file name>
Now we have to configure the game via
As of 12/25/2022, this is what my configuration looks like. Config options are liable to change in the future.
Here is the config I am using to run an FRC Rapid React Server:
chmod +x ./runserver.sh chmod +x './xRC Simulator.x86_64' kill $(pgrep xRC) nohup './xRC Simulator.x86_64' \ -batchmode -nographics \ RouterPort=11115 \ Port=11115 \ game=10 \ # Change this to set what game your server will play FrameRate=60 \ tmode=On \ register=On \ Spectators=2 \ updatetime=30 \ maxdata=9000 \ startwhenready=On \ comment="My Team" \ # You should set this to your team's name; your server will show up in the list password="password" \ # Omit if you want your server to be open admin="Admin0" \ # Set this to whatever your username of choice is > log.txt &
To edit your config, use a text editor to open the
runserver.shfile. I used nano:
nano runserver.sh. Most of the above are the default, so you don't have to completely make a config from scratch.
After you've closed out of the config, there's one last thing to do before we can start it up: configure the firewall. That can be done simply with a couple commands:
# Allow ports 11115-11118 over UDP sudo ufw allow 11115:11118/udp # Reload the firewall for changes to take effect sudo ufw reload
Important: Depending on the cloud provider you use, you may have to configure other firewall settings within their interface.
Finally, we can run the server:
Go back to your xRC game, click "Find Servers" under the Multiplayer mode, and you should see your server with the command you configured in step 4.
Conclusion and Helpful Footnotes
I hope that this helps someone. Have fun!
For reference, here's the
readme.txt provided by xRC, as of v9.0d on 12/25/2022.
xRC Sim - V9.0d ------------------------------- Thank you for trying xRC Simulator! If you find any bugs, or have feature suggestions (or just want to say thank you), please go to: http://xRCSimulator.org/allforums Known Bugs: 1) If you run the server and client on the same machine and leave the IP field empty or set it to 127.0.0.1, than issues will arise once the client disconnects from the server. Specifically, it will cause the server to lose the network conection and all other players will lose connection as well. Workaround: use your external IP adress instead (e.g. go to whatismyip.com and try using that one). Command Line options: -runvr // Turns on VR for Windows during startup. You can always turn on/off VR in the game "Video" menu without using this option -batchmode // runs headless. Will use Graphics card in windows if able for physics simulation -nographics // In windows, disables use of graphics card even for physics simulation The following are command-line options that will be read in if running in batchmode (case insensitive): GAME=# // Starts the game specified: 0="Splish Splash" 1="Relic Recovery" 2="Rover Ruckus" 3="Skystone" 4="Infinite Recharge" 5="Change Up" 6="Bot Royale" 7="Ultimate Goal" 8="Tipping Point" 9="Freight Frenzy" 10="Rapid React" 11="Spin Up" 12="Power Play" FRAMERATE=## // Sets the frame-rate for the server: 1 to 120. // Recommend setting it to ~60 TMODE=ON/OFF // Turn on/off tournament mode STARTWHENREADY=ON/OFF // Enables/Disbales option to start tournament mode when all users specify they are ready. HOLDINGMODE=ON/OFF // Turn on/off holding mode when people are waiting for game to start. GAMEOPTION=# // Sets the game option, from 1 to 5. Not every game uses this options setting. PASSWORD=XXXXX // Set the password to XXXX. Put in quotation mark (e.g. "XX XX") if space is part of password. No '=' allowed. SPECTATORS=# // Maximum number of spectators to allow. Spectators use up bandwidth so limitting ensured smoother gameplay. PORT=#### // The local machine port to open ROUTERPORT=#### // Set the router (or firewall) port #. This is the port that other users will try to connect to and needs to // be forwarded to your local port. // If firewall isn't used (e.g. direct connection as when running server in the cloud), set to the same value as PORT. REGISTER=ON/OFF // If set to On, will register server for others to find COMMENT="Comment..." // Set the server comment/description UPDATETIME=## // Sets the client update time in ms. The server's network update frame-rate is the inverse of this (e.g. 1/UPDATETIME). // 33 = 30 Frames/s, 25 = 40 Frames/s. Lower is better/smoother, but if set too low it will flood the network causing // buffer over-runs resulting in choppy/jittery performance. The more data sent, the higher this needs to be to avoid // issues. Highest data sent is when the most objects are moving - usually near end-game. I would avoid setting it below // 25 unless you know what you're doing. MAXDATA=#### // Sets the maximum bytes to send in any instance before cooling off. This helps spread data out and minimized packet-loss. // When set too low, will cause cool-off period to slow down frame-rate. When set too high, can result in packet-loss and jittery // performance. Recommend 3000 to be safe, 6000 on good network connections, even higher. ADMIN=<user> // Sets the admin user name. Admin user name is never displayed when sending chats, allowing this field to be in-itself a password (as long as // you only log in as a spectator). NETSTATS=ON/OFF // Output outgoing packet statistics every minute. Mainly useful for helping debug high bandwidth utilization OUTPUT_SCORE_FILES=<DIR PATH> // Turns on output files containing current score states to specified directory GAMESETTINGS="x:x:x:..." // Game specific option string. You can infer this string from the "Clean" code results in single-player mode (it's the part that looks like "1:0: ... " Example: "xRC Simulator.exe" -batchmode -nographics -game=4 port=11115 routerport=11115 register=on admin=GF11115 In-Game Chat options (press ~ to begin chat): Multi-Player And Server: /SET OUTPUT_SCORE_FILES /SET OUTPUT_SCORE_FILES=C:\temp\xRCsim Turns on output files containing current score states. Default path = \temp\xRCsim if none entered. Multi-Player: /SET TURN_OFF_HUD Turns off all overlays. Press ~ to re-enable. /SET FIREWORKS_RED /SET FIREWORKS_BLUE Plays the fireworks animation (only on this client). /SET SHOW_VS Shows the "VS" screen. Screen appears instantly - no animation (only on this client). /SET HIDES_VS Hides the "VS" screen. Screen hides instantly - no animation (only on this client). /SET HIDE_CHAMPS Turns off the championship field (stadium, lights, etc...) Server: /SET PASSWORD=NEW_PASSWORD Changes server password to NEW_PASSWORD. /SET TOURNAMENT Forces the start of tournament game (even if server wasn't enabled in tournament mode). Admin: /SERVER RESTART Starts/Restarts the game. First the "vs" window will be shown for 4s followed by the 3s countdown. /SERVER STOP Stops current game. /SERVER KICKALL Kick all users (except for Admin) /SERVER KICK=<player name> Kick specified player /SERVER KICKID=<#> Kick player with id=<#>. This is a unique integer identifier each player is given internally /SERVER PASSWORD=<NEW PASSWORD> Changes server password /SERVER BLUEADJ=<##> /SERVER REDADJ=<##> Adds the number to the score. Can be a negative number. Number is the total adjustment (not incremental). /SERVER <CommandLineOption> All command line options will also be processed. Some (like changing port) will have no effect since network is already established. OBJ Control If you enable OUTPUT_SCORE_FILES, then you can have OBJ send commands back to xRCSim by putting them into "execute.txt" in the output score file directory. Included is the script "xRCSimCommand.lua". This script allows you to associate commands that will be sent to xRCSim when the desired scenes are activated. Step 1) Load the scipt in OBS (under Tools->Scripts) In the Scripts Option window: Step 2) Specify the file to output the commands to (e.g. \tmp\xRCSim\execute.txt ) Step 3) For each scene listed, enable the toggle to execute your command, and enter what command you would like to execute. (e.g. /SERVER RESTART) Several useful examples: Example1: /SET SHOW_VS \n/SERVER RESTART Turns on the "vs" window without animation on the OBS client, and starts the server countdown sequence for all clients. Example2: /SET SHOW_VS Shows the "vs" screen on the OBS client. It will stay here indefinetaly. Example3: /SET HIDE_VS Hides the "vs" screen on the OBS client. SERVER-ONLY Builds: Server-only builds allow the stdin/stdout to be used as an input control. If you run the server in the foreground, press enter to get the list of suported commands. List of supported commands: \n" + PLAYERS - Get list of players (not spectators) SPECTATORS - Get list of spectators USERS - Get list of all users and their ID KICKALL - Kick all users (but not admin). KICKEVERYONE - Kick everyone including admin. KICK=<USER> - Kick user by name KICKID=<ID> - Kick user by ID GAMEINFO - Provides information about current game. RESTART - Restart game PASSWORD[=<password>] - Show game password and/or change it. ADMIN[=<name>] = Show admin name and/or change it.