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#
- Create a class library targeting
netstandard2.0, and referenceGodfather.dll(it ships with the engine inAssets/Plugins/Godfather/, and is built fromsrc/Godfatherin the Godfather-API repo). - Subclass
Gamemodeand mark it with[Gamemode("your-id")]. Override the events you care about; everything else has a safe default. - Drop your DLL in the server's
plugins/folder and set"gameMode": "your-id"inserver.json.
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#
| Area | What it covers |
|---|---|
| Gamemode | Server start and stop, player joined and left, each tick, and whether players spawn on join. The server calls you; you never poll. |
| Player | Name, position, spawn, freeze, toasts, chat messages, kick, rename. |
| Camera | Fly-overs behind a panel, a flight down to the spawn, the normal camera (v0.2). |
| Storage | Buckets of JSON values and accounts with salted, slow password hashes, in a SQLite database (accounts and SQLite since v0.2). |
| HUD and wanted level | Money, 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). |
| UI | Server-described glass panels with tabs, text, fields, buttons, an error line and a busy state, plus toasts. See the UI kit. |
| Loading and versions | How the server finds and starts gamemodes. |
Next#
Vehicles and chat commands are on the roadmap. Every change is listed in the Godfather changelog.