Set up an MTA:SA gamemode: resources, admin rights and MySQL

Install a roleplay or freeroam gamemode on a free MTA: San Andreas server on Torchlite: upload resources, start them with the server, give yourself admin and connect Lua scripts to MySQL.

4 min readBy Torchlite teamUpdated

Set up an MTA:SA gamemode: resources, admin rights and MySQL
On this page

A new MTA: San Andreas server on Torchlite starts with the default resources, so you can join and drive around straight away. A community server needs more: a gamemode such as roleplay, freeroam or race, its scripts and maps, admin rights for you, and often a MySQL database for accounts. In MTA all of it is made of resources, and this guide takes you from the default server to your own gamemode.

How resources work

Everything on an MTA server is a resource: a folder, or a .zip, with a meta.xml file that lists its Lua scripts, maps and files. The gamemode is a resource, the admin panel is a resource, and so is each map. Resources live in mods/deathmatch/resources. The server loads them and sends their client files to players when they join.

A gamemode you download from the MTA community or buy from a scripter usually comes as several resources that work together: the gamemode itself, a login or account resource, an inventory, a HUD and so on. Its readme names the ones to start, and in which order.

Upload the gamemode

  1. Stop the server.
  2. Open Files in the panel, or connect over SFTP, which is faster for many files.
  3. Go to mods/deathmatch/resources and upload each resource as a folder or a .zip. Keep the folder names exactly as they are: other resources refer to them by name.
  4. Start the server, then type refresh in the console so it finds the new resources.
  5. Start each one with start name, in the order the readme gives. The console says whether it started or prints the error that stopped it.

Resources inside square-bracket folders, such as [gamemodes] or [maps], are found too: those folders only group them.

Start it with the server

Typing start after every restart gets old. Open mods/deathmatch/mtaserver.conf and add one line per resource, near the other <resource> lines:

xml
<resource src="myrp_accounts" startup="1" protected="0" />
<resource src="myrp" startup="1" protected="0" />

They start in the order they are listed. While you are in the file you can also set <servername>, the name players see in the server browser, <maxplayers>, and <password> if you want a private server. Leave the port settings as they are: the panel sets them on every start.

Make yourself admin

  1. In the console, type addaccount yourname yourpassword.
  2. Stop the server, open mods/deathmatch/acl.xml, find the group named Admin and add <object name="user.yourname" /> to it.
  3. Start the server, join, and type /login yourname yourpassword in chat.

With the admin resource running, P opens the admin panel. Give other staff accounts their own, smaller groups from the same file rather than full Admin.

Connect the gamemode to MySQL

Roleplay gamemodes keep accounts, vehicles and houses in a database. MTA can use a local SQLite file, which needs no setup, or MySQL. Every Torchlite server can have one MySQL database at no cost:

  1. In the panel, open Databases, click New Database, give it a name and leave Connections from at %.
  2. Open it to see the Database Details: the Endpoint (host and port, such as mysql.torchlite.host:3306), the username and the password.
  3. Put them where the gamemode reads its database settings, usually a config file or the top of a server-side Lua script. In Lua the connection looks like this:
lua
local db = dbConnect("mysql", "dbname=s12_myrp;host=mysql.torchlite.host;port=3306;charset=utf8mb4", "u12_abcdef", "the-password")
if not db then outputDebugString("MySQL connection failed", 1) end
  1. If the gamemode ships a .sql file with its tables, import it with HeidiSQL, DBeaver or any MySQL client on your computer, connected to the same endpoint.

Never use localhost: the database runs on a separate database server. The MySQL guide covers creating the database in more detail.

Keep it running

A free server runs while you renew it in the panel, every 50 minutes on Lite and 40 on Turbo. For an evening of roleplay, keep the panel open in a tab and press Renew when it asks. A missed renew only stops the server; press Start and the same resources load again. The renewal guide explains every rule. Make a backup before you update the gamemode.

Common problems

"Couldn't find resource" after uploading

The server has not looked for new resources yet. Type refresh, then start again. If it still fails, the folder has no meta.xml at its top level: a .zip that contains another folder inside it is the usual cause.

A resource starts and stops at once

The console prints the Lua error, with the file and line. A missing resource it depends on is the most common cause; start that one first.

Players hang on "Downloading"

Large maps and textures take a while on the first join. MTA keeps them on the player's computer, so the next join is quick.

"Access denied" when using admin commands

You are not logged in, or your account is not in the Admin group in acl.xml. Log in with /login, and check the user.yourname line was saved while the server was stopped.

Stuck on a step?

Ask on the forum. Your question links back to this guide, so whoever answers knows where you are.

Ask about this guide

About the author

Torchlite team

The people who run Torchlite

We build and run the Torchlite panel and the nodes. Every guide is checked on our own servers before it goes up, and updated when the panel changes.

Found a mistake? Tell us on Discord

Related guides

All guides →