Gamemode API for Alt:SA

Write a San Andreas server in C#.

Godfather is the API every Alt:SA gamemode is built on: what happens when a player joins, where they spawn, what they see on screen and what the server remembers about them. It stays small and versioned, so gamemodes keep working as the engine changes.

v0.1in design, no code yet
C#gamemodes are class libraries
4areas: lifecycle, players, storage, UI
NG-RPfirst gamemode on it
What a gamemode looks like

One class, a few events.

This is the shape v0.1 is aiming for. Names may still change before release; the API page tracks the current draft.

  1. Create a class libraryReference Godfather.API.dll and target the same .NET profile as the engine.
  2. Subclass GamemodeOverride the events you care about. Everything else has a safe default.
  3. Drop the DLL in plugins/The dedicated server loads it on start and names it in the server list.
using Godfather;

[Gamemode("hello-godfather", Version = "0.1.0")]
public sealed class HelloGodfather : Gamemode
{
    public override void OnPlayerJoined(Player player)
    {
        player.Freeze();
        player.Camera.FlyOver(Landscape.Default);

        var panel = UI.Panel(player, "Welcome");
        panel.Text($"Hi {player.Name}, ready?");
        panel.Button("Play", () =>
        {
            panel.Close();
            player.Spawn(Spawn.Default);
            player.Toast("Good luck out there.");
        });
    }

    // Stored per player on the server (SQLite by default).
    public override void OnPlayerLeft(Player player)
        => Storage.For(player).Set("lastPosition", player.Position);
}
What's in v0.1

Four areas, nothing more.

Lifecycle

Server start and stop, player joined and left, each tick. The server calls you; you never poll.

Players

Name, spawn, position, freeze and camera, including the landscape fly-over used behind sign-in.

Storage

A small key-value interface per player and per server, with SQLite underneath.

UI kit

Black-glass panels, fields, buttons and toasts. The server decides what to show and the client draws it.

Latest release

Release notes are written once as data and shown here, in the changelog and in the repository.