SL:MP – Simple Lua Multiplayer for GTA: San Andreas

An open-source multiplayer for GTA: San Andreas written entirely in Lua: the client runs on a clean game with MoonLoader, the server on LuaJIT for Windows and Linux.

Author: Project: 2020Updated: 2 min read

SL:MP (Simple Lua Multiplayer) is an open-source multiplayer for GTA: San Andreas that SEVEN and I developed in 2020–2021. It's written entirely in Lua: the client is a set of MoonLoader scripts running inside the game, and the server runs on LuaJIT for Windows and Linux.

SL:MP banner: Simple Lua Multiplayer, developers Pakulichev and Seven.exe
Project banner from the BLAST.HK thread, 2020

How the project started

It began in August 2020 as an experiment: could we sync players using nothing but LuaSocket on top of SA:MP? It worked, and the experiment quickly turned into a project of its own.

How it evolved:

  1. A prototype on top of SA:MP, with player positions sent via LuaSocket.
  2. Then the SA:MP dependency was dropped, and the multiplayer ran on a clean GTA: San Andreas 1.0 US with only MoonLoader installed.
  3. The protocol went from compressed JSON to serialized Lua tables and finally to the custom binary SL:NET protocol over UDP.
  4. A standalone LuaJIT server for Windows and Linux appeared, along with a Java launcher and an ImGui interface.

The project thread on BLAST.HK opened on August 23, 2020 with an "Exclusive" tag, and the first public release was out by August 25.

Features

  • on-foot sync within a configurable stream zone (about 10 players near each other in tests);
  • vehicle sync for the driver and passengers;
  • three types of dialogs: info, input field and list;
  • pickups, including inside interiors;
  • virtual worlds to separate players into dimensions;
  • game patching examples using memory and LuaJIT FFI.

Architecture

Part Technologies Purpose
Client Lua, MoonLoader, LuaJIT FFI Runs in the game, sends and applies sync
Server LuaJIT, LuaSocket Accepts players, broadcasts data, runs the game mode
Protocol UDP, SL:NET Binary packets with a custom bitstream
Launcher Java, ImGui Server list and connecting

Later I moved the networking code into a separate library, SNET.

Server configuration

The server is configured with the server.cfg file:

serverName = My SL:MP Server
version    = 1.0.0
gamemode   = freeroam
maxSlots   = 10
stream     = 200
address    = 0.0.0.0
port       = 7777

The default port is 7777, same as SA:MP. The serverName, gamemode and stream values in the example are placeholders.

Releases

Version Date
0.0.1-Alpha 25.08.2020
Alpha rev.2 – rev.4 26–28.08.2020
RC5, RC6 29.08.2020
RC7 30.08.2020
RC8 01.09.2020
RC9 06.09.2020
0.0.1-RC-X 12.09.2020
1.0.0-alpha.1 18.01.2021

Ten builds came out in the first month alone. The 0.0.1-RC-X client was downloaded over 200 times and the server (Windows and Linux) about 170 times; 1.0.0-alpha.1 got over 200 client downloads. The project repository has more than 120 commits.

Team

I was the lead developer (about 100 of the 124 commits) and published the releases. SEVEN co-authored the project. Thanks to imring, FYP (the author of MoonLoader) and Akionka, who wrote the bitstream encoder for SL:NET.

I still count the SL:MP and SL Team days among the best times I had in GTA: San Andreas modding.

Frequently asked questions

Does SL:MP require SA:MP?

No. The first experiments ran on top of SA:MP, but the dependency was removed back in 2020: SL:MP runs on a clean GTA: San Andreas 1.0 US with MoonLoader.

Who developed SL:MP?

SL:MP was developed by Pakulichev and SEVEN (the SL Team). The project credits imring, FYP and Akionka – the author of the bitstream encoder for the SL:NET protocol.

How many players does SL:MP support?

The number of slots is set by the maxSlots parameter in server.cfg. During alpha testing the authors recommended no more than 10 players; in tests about 10 players near each other were synced.

How is SL:MP different from SA:MP and MTA?

SA:MP and MTA are mature C/C++ multiplayers with their own clients. SL:MP is an experimental project where both the client and the server are written in Lua: you can read, modify and extend it without touching native code.