Skip to content

Deploying MTA:SA

Introduction

MTA:SA (Multi Theft Auto: San Andreas) is a multiplayer modification for Rockstar Games’ Grand Theft Auto: San Andreas. This open-source project allows you to host game servers with custom gamemodes, scripts, and modifications, creating unique multiplayer experiences from roleplay to racing to zombie survival.

The MTA:SA server platform uses Lua scripting, enabling developers to create complex gamemodes and systems. With over 20 years of development, MTA:SA has a mature ecosystem with extensive documentation, community resources, and thousands of available scripts.

Key highlights of MTA:SA:

  • Full Multiplayer: Host servers with hundreds of concurrent players
  • Lua Scripting: Powerful scripting system for custom gamemodes
  • Custom Resources: Package scripts, maps, and assets into resources
  • Admin System: Built-in administration tools and commands
  • Anti-Cheat: Integrated anti-cheat system for fair play
  • Voice Chat: Built-in voice communication
  • Custom Maps: Create and share custom game maps
  • Vehicle/Skin Mods: Support for custom vehicles and character skins
  • SQLite/MySQL: Database support for persistent data
  • Web Interface: Optional web admin interface
  • Active Community: Large community with extensive resources
  • Open Source: GPLv3 licensed server and modification

This guide walks through deploying an MTA:SA server on Klutch.sh using Docker, configuring gamemodes, and managing your game server.

Why Deploy MTA:SA on Klutch.sh

Deploying MTA:SA on Klutch.sh provides several advantages:

Simplified Deployment: Klutch.sh automatically detects your Dockerfile and builds the MTA:SA server without complex configuration.

Persistent Storage: Attach persistent volumes for your resources, player data, and configurations. Your server state survives restarts.

GitHub Integration: Connect your configuration repository directly from GitHub for automated deployments.

Scalable Resources: Allocate CPU and memory based on expected player count.

Environment Variable Management: Securely store server passwords and API keys through Klutch.sh’s environment variable system.

Always-On Availability: Your game server remains accessible 24/7.

Prerequisites

Before deploying MTA:SA on Klutch.sh, ensure you have:

  • A Klutch.sh account
  • A GitHub account with a repository for your MTA:SA configuration
  • Basic familiarity with Docker and containerization concepts
  • Understanding of MTA:SA server administration
  • Game resources and scripts for your gamemode
  • (Optional) Custom maps and modifications

Understanding MTA:SA Architecture

MTA:SA servers use a resource-based architecture:

Server Core: The main server executable handling networking and game logic.

Resources: Lua scripts packaged with maps, images, and other assets.

ACL System: Access Control List for permissions and admin rights.

Accounts: Player account system for authentication and data storage.

Database: SQLite (built-in) or MySQL for persistent data storage.

Web Server: Optional HTTP interface for downloads and admin.

Preparing Your Repository

To deploy MTA:SA on Klutch.sh, create a GitHub repository containing your configuration.

Repository Structure

mtasa-deploy/
├── Dockerfile
├── mods/
│ └── deathmatch/
│ ├── mtaserver.conf
│ ├── acl.xml
│ └── resources/
│ └── [your-resources]/
├── README.md
└── .dockerignore

Creating the Dockerfile

Create a Dockerfile in the root of your repository:

FROM debian:bullseye-slim
# Install dependencies
RUN apt-get update && apt-get install -y \
wget \
tar \
libncursesw5 \
&& rm -rf /var/lib/apt/lists/*
# Create MTA directory
WORKDIR /opt/mta
# Download MTA:SA server
RUN wget -q https://linux.mtasa.com/dl/multitheftauto_linux_x64.tar.gz \
&& tar -xzf multitheftauto_linux_x64.tar.gz \
&& rm multitheftauto_linux_x64.tar.gz \
&& mv multitheftauto_linux_x64/* . \
&& rm -rf multitheftauto_linux_x64
# Copy configuration and resources
COPY mods/deathmatch/mtaserver.conf /opt/mta/mods/deathmatch/mtaserver.conf
COPY mods/deathmatch/acl.xml /opt/mta/mods/deathmatch/acl.xml
COPY mods/deathmatch/resources/ /opt/mta/mods/deathmatch/resources/
# Set permissions
RUN chmod +x /opt/mta/mta-server64
# Expose game ports
EXPOSE 22003/udp
EXPOSE 22005/tcp
EXPOSE 22126/udp
# Health check
HEALTHCHECK --interval=30s --timeout=10s --start-period=30s --retries=3 \
CMD pgrep mta-server64 || exit 1
CMD ["./mta-server64", "-n"]

Server Configuration

Create mods/deathmatch/mtaserver.conf:

<config>
<!-- Server name displayed in server browser -->
<servername>My MTA:SA Server</servername>
<!-- Server ports -->
<serverport>22003</serverport>
<httpport>22005</httpport>
<!-- Maximum players -->
<maxplayers>128</maxplayers>
<!-- Server password (empty for public) -->
<password></password>
<!-- ASE settings for server browser -->
<ase>1</ase>
<donotbroadcastlan>0</donotbroadcastlan>
<!-- Logging -->
<logfile>logs/server.log</logfile>
<!-- Resources to start -->
<resource src="admin" startup="1" protected="1"/>
<resource src="defaultstats" startup="1"/>
<resource src="helpmanager" startup="1"/>
<resource src="joinquit" startup="1"/>
<resource src="mapcycler" startup="1"/>
<resource src="mapmanager" startup="1" protected="1"/>
<resource src="parachute" startup="1"/>
<resource src="performancebrowser" startup="1"/>
<resource src="resourcebrowser" startup="1" protected="1"/>
<resource src="resourcemanager" startup="1" protected="1"/>
<resource src="scoreboard" startup="1"/>
<resource src="spawnmanager" startup="1"/>
<resource src="voice" startup="1"/>
<resource src="votemanager" startup="1"/>
<resource src="webadmin" startup="1" protected="1"/>
<!-- Your custom gamemode -->
<resource src="freeroam" startup="1"/>
</config>

Creating the .dockerignore File

Create a .dockerignore file:

.git
.github
*.md
LICENSE
.gitignore
*.log
.DS_Store
.env
.env.local

Environment Variables Reference

VariableRequiredDefaultDescription
SERVER_NAMENo-Server display name
SERVER_PASSWORDNo-Server join password
MAX_PLAYERSNo128Maximum concurrent players
ADMIN_PASSWORDYes-Admin account password

Deploying MTA:SA on Klutch.sh

Once your repository is prepared, follow these steps to deploy:

    Prepare Your Resources

    Gather your gamemode resources:

    1. Download or create your gamemode scripts
    2. Organize resources in the resources directory
    3. Configure resource dependencies
    4. Test locally if possible

    Push Your Repository to GitHub

    Initialize your repository and push to GitHub:

    Terminal window
    git init
    git add Dockerfile mods/ .dockerignore README.md
    git commit -m "Initial MTA:SA server deployment"
    git remote add origin https://github.com/yourusername/mtasa-deploy.git
    git push -u origin main

    Create a New Project on Klutch.sh

    Navigate to the Klutch.sh dashboard and create a new project. Give it a descriptive name like “mtasa” or “game-server”.

    Create a New App

    Within your project, create a new app. Connect your GitHub account if you haven’t already, then select the repository containing your MTA:SA Dockerfile.

    Configure Traffic

    MTA:SA requires specific ports:

    • UDP port 22003 for game traffic
    • TCP port 22005 for HTTP downloads
    • UDP port 22126 for server browser

    Note: Consult Klutch.sh documentation for UDP port configuration.

    Set Environment Variables

    In the environment variables section, add:

    VariableValue
    SERVER_NAMEMy MTA:SA Server
    MAX_PLAYERS128
    ADMIN_PASSWORDYour secure admin password

    Attach Persistent Volumes

    Add the following volumes:

    Mount PathRecommended SizePurpose
    /opt/mta/mods/deathmatch/resources5 GBGame resources and scripts
    /opt/mta/mods/deathmatch/logs1 GBServer logs
    /opt/mta/mods/deathmatch/accounts500 MBPlayer accounts database

    Deploy Your Application

    Click Deploy to start the build process. Klutch.sh will:

    • Detect your Dockerfile automatically
    • Build the container image
    • Attach the persistent volumes
    • Start the MTA:SA server

    Connect to Your Server

    Once deployment completes, connect using the MTA:SA client with your server IP and port.

Server Administration

Admin Access

Set up admin accounts:

  1. Connect to your server
  2. Use the console or in-game commands
  3. Add yourself to the Admin group in acl.xml

Common Commands

Server administration commands:

start [resource] - Start a resource
stop [resource] - Stop a resource
restart [resource] - Restart a resource
refresh - Refresh resource list
kick [player] - Kick a player
ban [player] - Ban a player

Web Admin

Access the web admin interface:

  1. Enable webadmin resource in config
  2. Access via http://your-server:22005/
  3. Log in with admin credentials
  4. Manage server remotely

Resource Development

Basic Resource Structure

Create custom resources:

myresource/
├── meta.xml
├── server.lua
├── client.lua
└── assets/
└── images/

Meta.xml Example

<meta>
<info author="Your Name" version="1.0.0" name="My Resource"/>
<script src="server.lua" type="server"/>
<script src="client.lua" type="client"/>
</meta>

Server Script Example

-- server.lua
addEventHandler("onPlayerJoin", root, function()
outputChatBox("Welcome to the server!", source)
end)

Available Gamemodes

Common MTA:SA gamemodes:

  • Roleplay: Life simulation with jobs, economy, housing
  • Race: Vehicle racing with custom tracks
  • DayZ: Zombie survival gameplay
  • Freeroam: Open sandbox mode
  • Deathmatch: Player vs player combat
  • Cops and Robbers: Law enforcement gameplay

Gamemode Resources

Find resources at:

  • MTA:SA Community forums
  • GitHub MTA:SA repositories
  • Resource sharing websites

Production Best Practices

Security Recommendations

  • Strong Passwords: Use strong admin passwords
  • ACL Configuration: Properly configure access control
  • Resource Verification: Only use trusted resources
  • Regular Updates: Keep server and resources updated
  • Log Monitoring: Review logs for suspicious activity

Performance Optimization

  • Resource Management: Only run necessary resources
  • Script Optimization: Optimize Lua scripts for performance
  • Player Limits: Set appropriate max player counts
  • Hardware Scaling: Scale resources based on player count

Backup Strategy

Protect your server data:

  1. Account Backups: Regularly back up player accounts
  2. Resource Backups: Version control your resources
  3. Database Backups: Back up any MySQL databases
  4. Configuration Backups: Preserve ACL and server configs

Troubleshooting Common Issues

Server Not Appearing in Browser

Symptoms: Server doesn’t show in MTA:SA server browser.

Solutions:

  • Verify ASE is enabled in config
  • Check port forwarding for UDP 22126
  • Ensure server is fully started
  • Wait for server list refresh

Players Cannot Connect

Symptoms: Connection timeouts or rejections.

Solutions:

  • Verify port configuration
  • Check server password settings
  • Review firewall rules
  • Check server logs for errors

Resource Errors

Symptoms: Resources fail to start or crash.

Solutions:

  • Check resource syntax in meta.xml
  • Review Lua script errors in logs
  • Verify all dependencies are available
  • Test resource in isolation

Additional Resources

Conclusion

Deploying MTA:SA on Klutch.sh gives you a powerful platform for hosting custom Grand Theft Auto: San Andreas multiplayer experiences. The combination of MTA:SA’s extensive scripting capabilities and Klutch.sh’s deployment simplicity means you can focus on creating engaging gameplay rather than server management.

With Lua scripting, custom resources, and a mature ecosystem, MTA:SA enables everything from casual freeroam servers to complex roleplay communities. Whether you’re starting a new gaming community or migrating an existing server, MTA:SA on Klutch.sh provides the reliable, always-available infrastructure you need.