Getting started with Client-side
What the player's game does in Alt:SA, why there is no client scripting, and how the server draws UI on players' screens.
Introduction#
On many multiplayer platforms you write two programs: one for the server and one that runs on each player's PC. Alt:SA works differently. Your gamemode runs only on the server. The client is the Alt:SA engine itself, and it draws what the server describes.
This keeps things simple and safe: there is no code to download into players' games, and the server stays in charge of game state.
What the client does for you#
| You call on the server | The client shows |
|---|---|
UI.Panel(player, title) and its tabs, text, fields and buttons | A centered glass panel from the UI kit; the cursor is free and game input pauses while it's open |
player.Toast(text, kind) | A short message in the top right, under the radar area |
player.Hud.Money, SetStrip, StartTimer, SetWaypoint, Hide | The GTA V-style HUD: money, strips under the radar, timers, the GPS route, hidden pieces (HUD and wanted level) |
player.Wanted.Level | Wanted stars and the police search area on the radar |
player.Freeze() / Unfreeze() | Stops or restores movement and input |
player.Kick(reason) | The reason, then the disconnect |
player.Camera.FlyOver(...), FlyTo(...), Follow() | A slow circle over the city, a flight down to a point, then the normal camera |
Your first screen#
This shows a panel when a player joins and spawns them when they press Spawn:
1public override bool SpawnOnJoin => false;2 3public override void OnPlayerJoined(Player player)4{5 player.Freeze();6 7 var panel = UI.Panel(player, "Welcome");8 panel.Text($"Hi {player.Name}, ready?");9 var note = panel.Field("Say hello (optional)");10 panel.Button("Spawn", () =>11 {12 if (note.Value.Length > 0) Log.Info($"{player.Name} says: {note.Value}");13 panel.Close();14 player.Unfreeze();15 player.Spawn(Spawn.Default);16 });17}The button's callback runs on the server. The client only sends back which button was pressed and what's in the fields. When a gamemode shows a panel before the player has spawned, the loading screen hands over to it straight away.
Final notes#
You have drawn your first client screen without writing client code. See every component in the UI kit.