Server Manual: Difference between revisions

From Multi Theft Auto: Wiki
Jump to navigation Jump to search
No edit summary
m (replaced http links with https)
 
(84 intermediate revisions by 42 users not shown)
Line 2: Line 2:


==Getting started==
==Getting started==
It is much easier than it looks to get a server up and running for your internet or LAN buddies: follow this wiki article and you will hopefully be on your way to hosting your own MTA:SA DM Server in no time!
It is much easier than it looks to get a server up and running for your internet or LAN buddies; follow this wiki article and you will hopefully be on your way to hosting your own MTA:SA server in no time!


==Installing the server==
==Installing the server==
Line 8: Line 8:


===Linux installation===
===Linux installation===
==Ubuntu==
There are different ways of getting a Linux server up and running:
I installed the server on ubuntu 6.05 LTS. I will add installation instructions for other linux distros at a later time.
* [https://linux.mtasa.com Getting a precompiled package]
This install was done on a fresh os install so a few things have to be installed first.
* [[Installing and Running MTASA Server on GNU Linux]]
First of all ssh into your server using whatever client you like. I prefer putty.
* [[Building MTASA Server on GNU Linux]]
Start by typing  '''sudo apt-get upgrade''' It will prompt you to put your password in again. After the upgrade is done running type
'''sudo apt-get install pico''' this will install the easy to use pico text editor that you will use to edit the config files.
After the install is done running you need to get a copy of libcurl3 for the server to run so type '''sudo apt-get install libcurl3'''
Once again it will ask you for your password. Once this is done now we have to get the server program onto your Linux server. There are a few methods for doing this. you can install a ftp server. you can use putty file transfer. If you know someone with a website you can ask them to put the file on their website then use '''wget http://wwww.websitename.com/file.tar''' Obviously where website name is change to your friends website. Either way once you have the tar file on your server you need to unpack it you do this by using the command '''tar -zxvf filename.tar'''
==Gentoo==
I assume that if people are using Gentoo, they know enough of an operating system to get files from the web to their server theirselves... (otherwise, look above and read the ubuntu part)


These versions I needed for DP2:


Update your gcc version to 4.2.2:
Should you have any problems with errors when starting the server some common problems and solutions are listed here:
* unmask gcc in /etc/portage/package.unmask)
* [[Building MTASA Server on GNU Linux#Troubleshooting]]
* emerge gcc
 
* switch to gcc 4.2.2: gcc-config i686-pc-linux-gnu-4.2.2
===FreeBSD installation===
Update your libstdc++ version to 3.3 if you haven't got that version
 
* emerge libstdc++
You can run MTA:SA under FreeBSD using Linux emulation.
Install libcurl:
* Enable [https://www.freebsd.org/doc/en_US.ISO8859-1/books/handbook/linuxemu-lbc-install.html Linux binary compatibility]
* emerge libcurl
* Install following packages or compile them from ports: hs-terminfo, linux_base-f10, linux-f10-sqlite3
Unpack mtasa, and run it...
* Install [https://linux.mtasa.com/ Linux precompiled package]


===Windows installation===
===Windows installation===
Installation of the MTA:SA DM server on Windows is easy as pie.
Installation of the MTA:SA server on Windows is easy as pie.
*Go to the [http://mtasa.com/dp.html download page] and scroll down to the "Dedicated servers" section
*Go to the [https://mtasa.com/ download page] and download the installer.
*Click the Windows download link.
*Once the installer is downloaded, open it.
*Once the installer is downloaded, open it.
*Select a folder where you want to install the server.
*Select a folder where you want to install the server.
Line 46: Line 38:


===General configuration===
===General configuration===
All general configuration options can be found in the 'mods/deathmatch/'''mtaserver.conf'''' file and can be opened by any regular text editor.
All general configuration options can be found in the 'mods/deathmatch/[[Server_mtaserver.conf|'''mtaserver.conf''']]' file and can be opened by any regular text editor.
 
This file is fairly straightforward; every variable has a [[Server_mtaserver.conf|description of what to do with it and how to change it]].
 
===Port forwarding===
If you run your server on your own private computer, and you have an router between the internet and your computer. You need to forward 3 ports.
 
First of all open the file 'mods/deathmatch/[[Server_mtaserver.conf|'''mtaserver.conf''']]' and search for the next lines:
<syntaxhighlight lang="xml">
<serverport>22003</serverport>
<httpport>22005</httpport>
</syntaxhighlight>
 
The ports are needed to setup the server correctly. We explain later how to set them, but first if you want your server to appear in the server browser there is another port we need, and that is the ASE port.
(quick example for how to turn ASE on or off):
<syntaxhighlight lang="xml">
<ase>1</ase> <!-- 0 = off, 1 = on -->
</syntaxhighlight>
 
Now we going to forward the ports in your router, which is not needed if you already have all ports open, or if you don't have a router with a firewall. If so, skip this part.
 
If you don't know how port forwarding works in your router, go to the [https://portforward.com/ Port Forward website], find your router model there, and follow the instructions there.
 
In almost every router you can set the port type: UDP or TCP. The following list will explain which port type is needed for what:
 
 
Main server port: UDP
 
HTTP Port: TCP
 
ASE Port: UDP (this is needed if you want your server to appear in the server list)
 
 
The ASE port is also simple to get:
 
ASE port = Main server port + 123
 
So, if you have the main server port set to 22003, then the ASE port will be 22126.
 
Good luck!
 
 
'''If you somehow get stuck while forwarding ports''' (and have looked for the aforementioned [https://portforward.com/ portforward.com] page designed for your router model, you can give this extended (generic) forwarding guide a try:
<br/>
[https://forum.mtasa.com/topic/115141-guide-port-forwarding-in-order-to-run-a-mta-server/ '''Port forwarding for MTA servers''']
 
 
''In the latest version of the server, you can check the port status by using the server command [[Server_Commands#openports|openports]].''
 
===Client Checks===
 
The MTA server can be configured to disable the anti-cheat. It can also allow specific or all files to be modified (e.g. carmods.dat), and make sure clients are of a minimum version.


This file is fairly straightforward; every variable has a description of what to do with it and how to change it.
All of these settings are within the file 'mods/deathmatch/[[Server_mtaserver.conf|'''mtaserver.conf''']]'. See the [[Anti-cheat_guide|Anti-cheat guide]] for more details.<br/>
 
If you want to force a minimum client version, search for the following line:
<syntaxhighlight lang="xml">
<minclientversion></minclientversion>
</syntaxhighlight>
Accepted values look like: 1.1.1-9.02320


===Adding administrators===
===Adding administrators===
Line 55: Line 104:
To add an administrator to your server, follow these steps:<br>
To add an administrator to your server, follow these steps:<br>
<ol>
<ol>
<li>Make sure your server is stopped; if your server is still running, all changes you make will be overwritten</li>
<li>While the server is running, add a new account by typing '''[[Server_Commands#addaccount|addaccount name password]]''' into the server window. For example, to add user BennyLava you could type:
<li>Open the file 'mods/deathmatch/'accounts.xml'''' with any text editor</li>
<div style="margin: 10px 10px 10px 10px;">
<li>Add a new account into the file by using the XML-syntax below, we use the username "BennyLava" with password "123password" for illustration purposes
<div style="padding: 10px">
<syntaxhighlight lang="xml">
<syntaxhighlight lang="xml">
<accounts>
addaccount BennyLava 123password
  ...
  <account name="BennyLava" password="123password" />
</accounts>
</syntaxhighlight>
</syntaxhighlight>
</div>
</div>
<li>Save and close the file</li>
<div style="margin: 10px 10px 10px 20px;">
<li>Open the file 'mods/deathmatch/'acl.xml'''' with any text editor</li>
''Note: If you do not have access to the server window, and the 'admin' resource is running, you can add  the example account by issuing the client console (F8) command '''register BennyLava 123password'''''
</div>
<li>The server should display a message confirming the account has been added.
<li>Next, shutdown the server by typing '''shutdown''' into the server window.
<li>Make sure your server is stopped; if your server is still running, the following changes you make will be overwritten</li>
<li>Open the file 'mods/deathmatch/acl.xml' with any text editor</li>
<li>Add the account to the ''Admin'' group by using the XML-syntax below
<li>Add the account to the ''Admin'' group by using the XML-syntax below
<div style="padding: 10px">
<div style="padding: 10px">
<syntaxhighlight lang="xml">
<syntaxhighlight lang="xml">
<ACL>
<acl>
   ...
   ...
   <group name="Admin">
   <group name="Admin">
Line 79: Line 128:
   </group>
   </group>
   ...
   ...
</ACL>
</acl>
</syntaxhighlight>
</syntaxhighlight>
</div>
</div>


You can actually add your user to any group you want. Each group is linked to an ACL ([[Access Control List]]). Each ACL contains a series of specific allowed or denied rights. These groups exist so different users can be assigned different rights. The ''Admin'' group points to the ''Admin'' ACL, which is empty (thus allowing all possible commands). The ''Everyone'' group points to the ''Default'' ACL that puts a series of restrictions on the available commands (to disallow regular players from using admin commands).
</li>
<li>
You're done! You can add as many administrators or users as you want this way, take a look at some of the other groups and ACLs for example. The ACL is also accessible through the [[Access_Control_List|Lua scripting engine]].<br>
You're done! You can add as many administrators or users as you want this way, take a look at some of the other groups and ACLs for example. The ACL is also accessible through the [[Access_Control_List|Lua scripting engine]].<br>


Line 91: Line 137:
</li>
</li>
</ol>
</ol>
'''Note 1''': Do not edit any of the .xml files while the server is running. Any changes you make will be overwritten!<br />
'''Note''': There are also ways to add accounts and edit rights for the server while it's running. "[[Server_Commands#addaccount|addaccount <user> <password>]]" is an internal command to add accounts, but you will have to use the web interface to add these accounts to specific groups/ACLs!<br />
'''Note 2''': Changing these files requires a restart of the server.<br />
 
'''Note 3''': There are also ways to add accounts and edit rights for the server while it's running. "addaccount <user> <password>" is an internal command to add accounts, but you will have to use the web interface to add these accounts to specific groups/ACLs!<br />
===Using the web interface===
===Using the web interface===
The dedicated server comes with a few Lua [[resources]] that provide a nice little web interface to your server. This can be used to easily maintain your server, as it allows you to add users, start/stop resources, and more.
The dedicated server comes with a few Lua [[resources]] that provide a nice little web interface to your server. This can be used to easily maintain your server, as it allows you to add users, start/stop resources, and more.
Line 100: Line 145:
<ol>
<ol>
<li>Make sure your server is stopped
<li>Make sure your server is stopped
<li>Open the file '''mods/deathmatch/mtaserver.conf''' with any text editor</li>
<li>Open the file 'mods/deathmatch/[[Server_mtaserver.conf|'''mtaserver.conf''']]' with any text editor</li>
<li>Verify that the HTTP server is enabled:
<li>Verify that the HTTP server is enabled:
<div style="padding: 10px">
<div style="padding: 10px">
Line 126: Line 171:
These are automatically started in the default configuration file, in case you just installed your server.
These are automatically started in the default configuration file, in case you just installed your server.
</li>
</li>
<li>Open a web browser (Internet Explorer 6 or 7 are NOT supported: use [http://www.mozilla.com/firefox Mozilla Firefox], [http://www.google.com/chrome Google Chrome], [http://www.apple.com/safari/download Apple Safari], [http://www.opera.com Opera] or others) and navigate to the HTTP server URL: '''http://server:port/'''. For example, If you are running a local server on HTTP port 22005, use '''http://127.0.0.1:22005/'''.</li>
<li>Open a web browser (Internet Explorer 6 or 7 are NOT supported; use [https://www.mozilla.com/firefox Mozilla Firefox], [https://www.google.com/chrome Google Chrome], [https://www.apple.com/safari/download Apple Safari], [https://www.opera.com Opera] or others) and navigate to the HTTP server URL: '''http://server:port/'''. For example, If you are running a local server on HTTP port 22005, use '''http://127.0.0.1:22005/'''.</li>
<li>Enter the username and password of the administrator you added in the previous section.</li>
<li>Enter the username and password of the administrator you added in the previous section.</li>
</ol>
</ol>
Line 134: Line 179:


=== Configuring an external web server ===
=== Configuring an external web server ===
The built-in web server is also used to serve files that are required by resources running on your server to any player that is connected to your server. For example, if you are running a game script with a scripted graphical user interface, or custom models, these need to be transferred to every connected player in order to function properly. This is done by either the built-in web server, or an external web server (that is usually a bit faster) but needs to be set up separately.
The built-in web server is also used to serve files that are required by resources running on your server to any player that is connected to your server. For example, if you are running a game script with a scripted graphical user interface, or custom models, these need to be transferred to every connected player in order to function properly. This is done by either the built-in web server, or an external web server (that is usually a bit faster) but needs to be set up separately.


For performance or consistency reasons during the game, you could choose to make use of such an external web server if you have one set up. The external web server needs to be accessible for the public, so any client will be able to download the necessary client-side files in order to join and play on your server.
For performance or consistency reasons during the game, you could choose to make use of such an external web server if you have one set up. The external web server needs to be accessible for the public, so any client will be able to download the necessary client-side files in order to join and play on your server.


To enable downloading off an external web server, you should configure the ''httpdownload'' and ''httpdownloadurl'' tags in your server configuration:
To enable downloading off an external web server, you should configure the [[Server_mtaserver.conf#httpdownloadurl|httpdownloadurl]] tag in your server configuration:


<div style="padding: 10px">
<div style="padding: 10px">
<syntaxhighlight lang="xml"><httpdownload>1</httpdownload>
<syntaxhighlight lang="xml">
<httpdownloadurl>http://www.myserver.tld/directory/here</httpdownloadurl>
<httpdownloadurl>http://www.myserver.tld/directory/here</httpdownloadurl>
</syntaxhighlight></div>
</syntaxhighlight></div>


Since all the default resources provided with the dedicated server are zipped, and are normally automatically extracted by the built-in web server, you now have to provide a way for the clients to download the unextracted files to their computers. The unextracted files are always available in the '''<SERVER>/mods/deathmatch/resourcecache''' directory.
When you launch the server, the directory '''<SERVER>/mods/deathmatch/resource-cache/http-client-files''' will contain the correct client files for hosting on an external web server. If the web server is on the same machine, you can simply link the appropriate web server directory to '''http-client-files'''. If the web server is on a separate machine, ensure it has access to '''http-client-files''' via a network path, or maintain a remote copy using synchronization software.


<ol>
'''Note 1''': Please try to avoid any special characters (e.g. ~, !) in your download URLs.<br />
<li>Launch the dedicated server once and exit again. This will extract the zip files into the '''<SERVER>/mods/deathmatch/resourcecache''' directory.</li>
'''Note 2''': Please do not use a trailing slash in your download URL (e.g. ''<nowiki>http://www.myserver.tld/directory</nowiki>'' rather than ''<nowiki>http://www.myserver.tld/directory/</nowiki>'')<br />
<li>Go into the directory above and copy the resources to your external web server's public directory, this can be done in several ways:
'''Note 3''': The web server must use 'ContentType: application/octet-stream' for Lua files. Most web servers will do this by default, or you can add the following line to the .htaccess file:<br />
<ul>
<div style="padding: 10px">
<li>If you don't care about your '''server-side files being publically available''': create a symbolic link (Linux), a junction (Windows) or just plain copy the contents of the '''resourcecache''' directory to your public web server directory.</li>
<syntaxhighlight lang="xml">AddType application/octet-stream .lua
<li>If you don't want your server files to be publically available through your web server: go into the '''resourcecache''' directory and manually copy the folders over to your public web server directory, removing any server-side files (they are '''not''' necessary for the client-side downloading) you do not want to be hosting on your web server.<br />
</syntaxhighlight></div>
<br />
A quick way of securing your server-side files is currently not available. We will investigate into developing a tool that automatically copies only the necessary client-side files for all resources on your server.
</ul>
</li>
</ol>


'''Note 1''': Please try to avoid any special characters (e.g. ~, !) in your download URLs.<br />
Instructions on how to install and configure Nginx as an external web server for MTA is here: [[Installing and Configuring Nginx as an External Web Server]]
'''Note 2''': Please do not use a trailing slash in your download URL (e.g. ''hxxp://www.myserver.tld/directory'' rather than ''hxxp://www.myserver.tld/directory/'')


==Starting your server==
==Starting your server==
Begin by making sure that you have finished all configuration of your server, starting your server is the last stage so everything must be ready!
Begin by making sure that you have finished all configuration of your server, starting your server is the last stage so everything must be ready!


To start your server double click on MTA Server.exe, make sure you allow it through any firewalls and forward ports where nessessary.
To start your server double click on MTA Server.exe, make sure you allow it through any firewalls and forward ports where necessary.


==Installing/Updating resources on your server==
==Installing/Updating resources on your server==
Resources can come in two formats, either a ZIP format or just a normal folder with the script files inside it. The MTA:SA DM server supports both these methods.
Resources can come in two formats, either a ZIP format or just a normal folder with the script files inside it. The MTA:SA server supports both these methods.


# Move or copy the new resource to your <SERVER>\mods\deathmatch\resources folder.
# Move or copy the new resource to your <SERVER>\mods\deathmatch\resources folder.
# In the server window type in the command "refresh" (without the quotes), this will re-scan the resources folder and update the live resources where necessary.
# In the server window type in the command [[Server_Commands#refresh|refresh]], this will re-scan the resources folder and update the live resources where necessary.


==Uninstalling resources==
==Uninstalling resources==
Line 182: Line 222:
You can start resources by typing the command "start resourcename" in the server console, or stop ones with "stop resourcename".
You can start resources by typing the command "start resourcename" in the server console, or stop ones with "stop resourcename".


It's also possible to execute these and other admin commands from the ingame console (which you can bring up with the ` key or F8); for this to work, you first need to log in with the command "login username password". Additionally, you can press the p key to bring up the admin panel: this is a graphical interface which allows you to easily kick or ban misbehaving players, among others.
It's also possible to execute these and other admin commands from the in-game console (which you can bring up with the ` key or F8); for this to work, you first need to log in with the command "[[Server_Commands#login|login username password]]". Additionally, you can press the p key to bring up the admin panel: this is a graphical interface which allows you to easily kick or ban misbehaving players, among others.


For further commands, type "help" in a console.
For further commands, type [[Server_Commands#help|help]] in a console.


==Starting a map/gamemode==
==Starting a map/gamemode==
See the commands section of the documentation for [[Resource:Map manager|mapmanager]] for more information.
See the commands section of the documentation for [[Resource:Map manager|mapmanager]] for more information.


==Remotely administrating your server==
==Keeping your server alive==
This article assumes you have setup a working account with 'Admin' user rights, and have these resources started:
 
# resourcebrowser
<!-- Moved from https://forum.mtasa.com/topic/65514-server-load-and-runtime-principles/ -->
# resourcemanager
# webadmin
# webmap


Please make sure that you have followed the steps above, involving creating your administrator account and setting it's right before you can access these tools.
To keep your server stable, you should avoid letting your server run unmanaged after you launched it.


You're able to access these great remote admin tools by visiting <nowiki>http://<yourserverip>:<httpport>/resourcebrowser</nowiki> in your Firefox.  
* It is good to keep an eye on the process memory usage in Task manager, use performancebrowser/ipb, if the MTA Server process starts using more than 1.2 gb you're close to an Out Of Memory (OOM) error. At this point, you should:
'''NOTE: Internet Explorer will NOT work, it will not display the resource browser, other browsers (Opera namely) will have mixed results'''. If you want it to work in Internet Explorer, feel free to recode the resource :)
** Restart the server
** Start checking for memory leaks in your code
* An OOM happens your server runs out of memory.
* Like with every process or application, not all elements and function calls can get efficiently freed.
* For example, if you start the server, you will have average memory usage of 50mb. If you have some players on it for a while, and all of them disconnected, you will have increased memory usage on the MTA Server process, even if the server returned to 0 players. This known as [https://www.google.com/search?q=software+aging ''software aging''].
* It is the leftover from the server's running time and can eventually increase until the server process can become unreliable and has chance of failure, memory exception or in other words, server crashes.
* To keep it short and simple: Always keep an eye on your servers and restart them once in a while to prevent this from happening, 50% of all server crashes asked support for are caused by it and it's better to be aware that you need this kind of mainentance to ensure stability!
* In other words: If you launch your server and leave it unmanaged for a long period, it won't hold out and it will crash at a certain point without the mainentance as described above. That means you cannot just start a server and not check back on it, because at one point you'll find it crashed if it gains memory usage over (very) long periods, depending on server load, player counts and other variables.


==Useful Notes==
==Useful Notes==


# You may also update the resources while ingame as long as you have the correct access levels by typing "refresh" in the clients console or "/refresh" in the chat window. This may cause a second of lag if you have many resources.
# You may also update the resources while in-game as long as you have the correct access levels by typing "refresh" in the clients console or "/refresh" in the chat window. This may cause a second of lag if you have many resources.
# In the above instructions, <SERVER> is the path to your server's main directory. In most cases this is C:\Program Files\MTA San Andreas\server
# In the above instructions, <SERVER> is the path to your server's main directory. In most cases this is C:\Program Files\MTA San Andreas\server
# You can choose a different config file for the server to use by passing it in the command line after a --config argument, e.g. mtaserver.exe --config anotherconfig.cfg.
# You can choose a different config file for the server to use by passing it in the command line after a --config argument, e.g. mtaserver.exe --config anotherconfig.cfg.
Line 209: Line 253:


====Need further help?====
====Need further help?====
Why not pop over to our [http://forum.mtasa.com/ Forums] or join us on [irc://irc.multitheftauto.com/mta IRC] (irc.multitheftauto.com #mta - [http://www.mirc.com MIRC])
Why not pop over to our [https://forum.mtasa.com/ Forums] or join us on [https://discord.com/invite/mtasa Discord].


[[de:Server Anleitung]]
[[en:Server Manual]]
[[es:Manual del Servidor]]
[[fr:Manuel Serveur]]
[[hu:Server Manual]]
[[it:Manuale del Server]]
[[it:Manuale del Server]]
[[nl:Server Manual]]
[[pl:Server Manual]]
[[pt-br:Manual do Servidor]]
[[ru:Server Manual]]
[[Category:Support]]

Latest revision as of 01:12, 3 January 2022

Getting started

It is much easier than it looks to get a server up and running for your internet or LAN buddies; follow this wiki article and you will hopefully be on your way to hosting your own MTA:SA server in no time!

Installing the server

The dedicated server application is available in different flavours depending on the platform of the server.

Linux installation

There are different ways of getting a Linux server up and running:


Should you have any problems with errors when starting the server some common problems and solutions are listed here:

FreeBSD installation

You can run MTA:SA under FreeBSD using Linux emulation.

Windows installation

Installation of the MTA:SA server on Windows is easy as pie.

  • Go to the download page and download the installer.
  • Once the installer is downloaded, open it.
  • Select a folder where you want to install the server.
  • Click Install.
  • Done!

For a full explanation of acl.xml (access control list) read: Access Control List

Configuring your server

The Multi Theft Auto dedicated server is initially configurable through it's console window, from within the game, and from a webbrowser. In order to make use of the two last options, it is necessary to add at least one administrator user to your configuration file.

General configuration

All general configuration options can be found in the 'mods/deathmatch/mtaserver.conf' file and can be opened by any regular text editor.

This file is fairly straightforward; every variable has a description of what to do with it and how to change it.

Port forwarding

If you run your server on your own private computer, and you have an router between the internet and your computer. You need to forward 3 ports.

First of all open the file 'mods/deathmatch/mtaserver.conf' and search for the next lines:

<serverport>22003</serverport> 
<httpport>22005</httpport>

The ports are needed to setup the server correctly. We explain later how to set them, but first if you want your server to appear in the server browser there is another port we need, and that is the ASE port. (quick example for how to turn ASE on or off):

<ase>1</ase> <!-- 0 = off, 1 = on -->

Now we going to forward the ports in your router, which is not needed if you already have all ports open, or if you don't have a router with a firewall. If so, skip this part.

If you don't know how port forwarding works in your router, go to the Port Forward website, find your router model there, and follow the instructions there.

In almost every router you can set the port type: UDP or TCP. The following list will explain which port type is needed for what:


Main server port: UDP

HTTP Port: TCP

ASE Port: UDP (this is needed if you want your server to appear in the server list)


The ASE port is also simple to get:

ASE port = Main server port + 123

So, if you have the main server port set to 22003, then the ASE port will be 22126.

Good luck!


If you somehow get stuck while forwarding ports (and have looked for the aforementioned portforward.com page designed for your router model, you can give this extended (generic) forwarding guide a try:
Port forwarding for MTA servers


In the latest version of the server, you can check the port status by using the server command openports.

Client Checks

The MTA server can be configured to disable the anti-cheat. It can also allow specific or all files to be modified (e.g. carmods.dat), and make sure clients are of a minimum version.

All of these settings are within the file 'mods/deathmatch/mtaserver.conf'. See the Anti-cheat guide for more details.

If you want to force a minimum client version, search for the following line:

<minclientversion></minclientversion>

Accepted values look like: 1.1.1-9.02320

Adding administrators

It is strongly recommended to add at least one administrator to your server in order to make use of the built-in webserver to easily maintain and configure your server. This administrator will then also be able to log-in from within the game and control the server.

To add an administrator to your server, follow these steps:

  1. While the server is running, add a new account by typing addaccount name password into the server window. For example, to add user BennyLava you could type:
    addaccount BennyLava 123password
    

    Note: If you do not have access to the server window, and the 'admin' resource is running, you can add the example account by issuing the client console (F8) command register BennyLava 123password

  2. The server should display a message confirming the account has been added.
  3. Next, shutdown the server by typing shutdown into the server window.
  4. Make sure your server is stopped; if your server is still running, the following changes you make will be overwritten
  5. Open the file 'mods/deathmatch/acl.xml' with any text editor
  6. Add the account to the Admin group by using the XML-syntax below
    <acl>
      ...
      <group name="Admin">
        <acl name="Admin"/>
        ...
        <object name="user.BennyLava" />
      </group>
      ...
    </acl>
    

    You're done! You can add as many administrators or users as you want this way, take a look at some of the other groups and ACLs for example. The ACL is also accessible through the Lua scripting engine.

    It is recommended to take a look at the web interface, we will explain how to do this below.

Note: There are also ways to add accounts and edit rights for the server while it's running. "addaccount <user> <password>" is an internal command to add accounts, but you will have to use the web interface to add these accounts to specific groups/ACLs!

Using the web interface

The dedicated server comes with a few Lua resources that provide a nice little web interface to your server. This can be used to easily maintain your server, as it allows you to add users, start/stop resources, and more.

The web interface resources are enabled by default and are served through the built-in HTTP web server. To make sure the built-in HTTP web server runs on a port you like (22005 by default), follow these steps:

  1. Make sure your server is stopped
  2. Open the file 'mods/deathmatch/mtaserver.conf' with any text editor
  3. Verify that the HTTP server is enabled:
    	<httpserver>1</httpserver>
    
  4. Change the HTTP server port to your liking:
    	<httpport>22005</httpport>
    
  5. Save and close the configuration file
  6. Start your server
  7. If you happened to have changed the start-up resources in your configuration file, make sure the following resources are started:
    1. resourcebrowser
    2. resourcemanager
    3. webadmin
    4. webmap
    These are automatically started in the default configuration file, in case you just installed your server.
  8. Open a web browser (Internet Explorer 6 or 7 are NOT supported; use Mozilla Firefox, Google Chrome, Apple Safari, Opera or others) and navigate to the HTTP server URL: http://server:port/. For example, If you are running a local server on HTTP port 22005, use http://127.0.0.1:22005/.
  9. Enter the username and password of the administrator you added in the previous section.


You should now be able to maintain your server from the web interface.

Configuring an external web server

The built-in web server is also used to serve files that are required by resources running on your server to any player that is connected to your server. For example, if you are running a game script with a scripted graphical user interface, or custom models, these need to be transferred to every connected player in order to function properly. This is done by either the built-in web server, or an external web server (that is usually a bit faster) but needs to be set up separately.

For performance or consistency reasons during the game, you could choose to make use of such an external web server if you have one set up. The external web server needs to be accessible for the public, so any client will be able to download the necessary client-side files in order to join and play on your server.

To enable downloading off an external web server, you should configure the httpdownloadurl tag in your server configuration:

	
<httpdownloadurl>http://www.myserver.tld/directory/here</httpdownloadurl>

When you launch the server, the directory <SERVER>/mods/deathmatch/resource-cache/http-client-files will contain the correct client files for hosting on an external web server. If the web server is on the same machine, you can simply link the appropriate web server directory to http-client-files. If the web server is on a separate machine, ensure it has access to http-client-files via a network path, or maintain a remote copy using synchronization software.

Note 1: Please try to avoid any special characters (e.g. ~, !) in your download URLs.
Note 2: Please do not use a trailing slash in your download URL (e.g. http://www.myserver.tld/directory rather than http://www.myserver.tld/directory/)
Note 3: The web server must use 'ContentType: application/octet-stream' for Lua files. Most web servers will do this by default, or you can add the following line to the .htaccess file:

AddType application/octet-stream .lua

Instructions on how to install and configure Nginx as an external web server for MTA is here: Installing and Configuring Nginx as an External Web Server

Starting your server

Begin by making sure that you have finished all configuration of your server, starting your server is the last stage so everything must be ready!

To start your server double click on MTA Server.exe, make sure you allow it through any firewalls and forward ports where necessary.

Installing/Updating resources on your server

Resources can come in two formats, either a ZIP format or just a normal folder with the script files inside it. The MTA:SA server supports both these methods.

  1. Move or copy the new resource to your <SERVER>\mods\deathmatch\resources folder.
  2. In the server window type in the command refresh, this will re-scan the resources folder and update the live resources where necessary.

Uninstalling resources

Resources can easily be removed from your server if you no longer want them.

  1. Delete the ZIP file or the folder of the resource you wish to uninstall
  2. In the server window type in the command "refresh" (without the quotes), this will re-scan the resources folder and update the live resources where necessary.

Administrating your server

You can start resources by typing the command "start resourcename" in the server console, or stop ones with "stop resourcename".

It's also possible to execute these and other admin commands from the in-game console (which you can bring up with the ` key or F8); for this to work, you first need to log in with the command "login username password". Additionally, you can press the p key to bring up the admin panel: this is a graphical interface which allows you to easily kick or ban misbehaving players, among others.

For further commands, type help in a console.

Starting a map/gamemode

See the commands section of the documentation for mapmanager for more information.

Keeping your server alive

To keep your server stable, you should avoid letting your server run unmanaged after you launched it.

  • It is good to keep an eye on the process memory usage in Task manager, use performancebrowser/ipb, if the MTA Server process starts using more than 1.2 gb you're close to an Out Of Memory (OOM) error. At this point, you should:
    • Restart the server
    • Start checking for memory leaks in your code
  • An OOM happens your server runs out of memory.
  • Like with every process or application, not all elements and function calls can get efficiently freed.
  • For example, if you start the server, you will have average memory usage of 50mb. If you have some players on it for a while, and all of them disconnected, you will have increased memory usage on the MTA Server process, even if the server returned to 0 players. This known as software aging.
  • It is the leftover from the server's running time and can eventually increase until the server process can become unreliable and has chance of failure, memory exception or in other words, server crashes.
  • To keep it short and simple: Always keep an eye on your servers and restart them once in a while to prevent this from happening, 50% of all server crashes asked support for are caused by it and it's better to be aware that you need this kind of mainentance to ensure stability!
  • In other words: If you launch your server and leave it unmanaged for a long period, it won't hold out and it will crash at a certain point without the mainentance as described above. That means you cannot just start a server and not check back on it, because at one point you'll find it crashed if it gains memory usage over (very) long periods, depending on server load, player counts and other variables.

Useful Notes

  1. You may also update the resources while in-game as long as you have the correct access levels by typing "refresh" in the clients console or "/refresh" in the chat window. This may cause a second of lag if you have many resources.
  2. In the above instructions, <SERVER> is the path to your server's main directory. In most cases this is C:\Program Files\MTA San Andreas\server
  3. You can choose a different config file for the server to use by passing it in the command line after a --config argument, e.g. mtaserver.exe --config anotherconfig.cfg.
  4. Do not be alarmed by the warning regarding the parsing of the settings.xml file. This happens because your server installation is still clean and unused.

Need further help?

Why not pop over to our Forums or join us on Discord.