Godfather overview

Godfather is the C# API Alt:SA gamemodes are written against: lifecycle, players, camera, storage and accounts, and a black-glass UI kit.

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.

What a gamemode looks like#

  1. Create a class library targeting netstandard2.0, and reference Godfather.dll (it ships with the engine in Assets/Plugins/Godfather/, and is built from src/Godfather in the Godfather-API repo).
  2. Subclass Gamemode and mark it with [Gamemode("your-id")]. Override the events you care about; everything else has a safe default.
  3. Drop your DLL in the server's plugins/ folder and set "gameMode": "your-id" in server.json.
C#
1using Godfather;2 3[Gamemode("hello-godfather", Version = "0.1.0")]4public class HelloGodfather : Gamemode5{6    // Players stay unspawned until they press "Spawn".7    public override bool SpawnOnJoin => false;8 9    public override void OnPlayerJoined(Player player)10    {11        player.Freeze();12        int before = Bucket.For(player).Get("visits", 0);13 14        var panel = UI.Panel(player, "Hello, Godfather", "Alt:SA example gamemode");15        panel.Text($"Welcome to San Andreas, {player.Name}.");16        panel.Button("Spawn", () =>17        {18            Bucket.For(player).Set("visits", before + 1);19            panel.Close();20            player.Unfreeze();21            player.Spawn(Spawn.Default);22            player.Toast($"Visit {before + 1}. Have fun.", ToastKind.Success);23        });24    }25}

The full example is examples/HelloGodfather in the Godfather-API repo.

What's in it#

AreaWhat it covers
GamemodeServer start and stop, player joined and left, each tick, and whether players spawn on join. The server calls you; you never poll.
PlayerName, position, spawn, freeze, toasts, chat messages, kick, rename.
CameraFly-overs behind a panel, a flight down to the spawn, the normal camera (v0.2).
StorageBuckets of JSON values and accounts with salted, slow password hashes, in a SQLite database (accounts and SQLite since v0.2).
HUD and wanted levelMoney, strips under the radar, timers, GPS waypoint, hiding HUD pieces; wanted stars with a police search area that clears after 6 s outside it (v0.3).
UIServer-described glass panels with tabs, text, fields, buttons, an error line and a busy state, plus toasts. See the UI kit.
Loading and versionsHow the server finds and starts gamemodes.

Next#

Vehicles and chat commands are on the roadmap. Every change is listed in the Godfather changelog.