In order to successfully build Multi Theft Auto from source, it is necessary to perform a number of steps, which we will explain below.
Please read the instructions carefully and do not skip parts of it, if you have no experience.
- 1 Prerequisites
- 2 Getting the latest source code
- 3 Compiling the code
- 4 Running the software
- 5 Getting involved
- 6 Additional information
You should be using Windows 7 or above, before you can compile the Multi Theft Auto client.
Make sure you have the following software and SDKs installed:
Visual Studio 2015
Microsoft Visual Studio 2015 (Community Edition is free).
Addon: EditorConfig (optional)
(Install this addon to automatically set up your IDE for the correct code formatting)
Addon: ReAttach (optional)
(ReAttach gives you an easy way to re-attach your prior debug targets)
Missing #include "afxres.h"
Make sure you have Microsoft Foundation Classes for C++ installed.
(You can re-run the installer to modify your current installation, no need to uninstall and reinstall)
Microsoft DirectX SDK
Microsoft DirectX SDK (August 2009)
You have three options here available. You can install ONE of the clients below (for collaboration) or download the entire codebase in a .ZIP file (if you only want to compile the code). You can also use Git on the command line to checkout the respository.
GitHub for Windows
Getting the latest source code
To get the latest code, you will have to download the latest copy of our Git repository.
We recommend cloning the repository in your Git client, because you can pull any updates from there easily.
Compiling the code
- Execute the script create-projects.bat
- Open the solution file MTASA.sln in the Build directory
- Compile in Visual Studio with Debug configuration (may take some minutes)
- Install data files: utils\premake5.exe install_data (Shift + Right-Click in the top-level directory and click on Open command window here)
- Install resources: utils\premake5.exe install_resources (optional step)
Running the software
Running the client
You can start your client in the Bin directory. You might find there a Multi Theft Auto.exe and/or Multi Theft Auto_d.exe executable. The _d suffix indicates a debug build of the software.
Furthermore, you can also run your client inside the debugger from Visual Studio if you want to investigate a stack trace or set breakpoints in interesting code regions (read more in the section Debugging below).
Running the dedicated server
If you already have run the step 5 (Install resources) in Compiling the code to install resources then you can goto Starting the server.
Installing the latest resources
If you want to run the Multi Theft Auto dedicated server, you will have to install the required resources. These are required because they implement the most basic functionality (e.g. spawning players) in order to play.
Starting the server
To run the server, open the MTA Server.exe executable in the Bin/server directory. The _d suffix indicates a debug build of the software.
You can also run the debug build MTA Server_d.exe with the Visual Studio Debugger (as of writing, you can do that by right-clicking on the Server's Launcher project and selecting Start a local instance in the Debugger menu), but you can also attach to a running debug build MTA server (see more in the section Debugging below).
If you already compiled the code in the Debug configuration then continue reading, if not, then go up to Compilling the code and follow the steps for a Debug build.
You can either launch MTA yourself and attach any debugger you want to use (also applies to the Visual Studio debugger) or you start a local debugging session in Visual Studio.
If you choose to run MTA with Visual Studio then you should also attach the debugger to the executable gta_sa.exe (press CTRL + ALT + P in Visual Studio) - otherwise your breakpoints will not work for anything beside the MTA Launcher project.
Furthermore, it is advisable to create an empty "timeout.longtime" file in your Bin/server/ directory
This will extend the time before players are kicked from your server for unresponsiveness to 120 seconds. This is useful when in Debug mode on the client and the process is halted.
You can use ReAttach to re-attach the debugger to the gta_sa.exe executable whenever you start your local debugger in Visual Studio.
Please see our Coding guidelines for information on coding practice.