HUD and wanted level

Drive the player's GTA V-style HUD from the server (money, strips, timers, GPS, stats, sights, hiding pieces) and give them a wanted level with a police search area.

Since v0.3 a gamemode can drive each player's HUD: the Alt:SA engine draws it in the GTA V-style layout (radar bottom left, money and stars top right, timers top left, area and stats bottom right). Players can still turn pieces off in Options → HUD. The weapon wheel, radio wheel, phone and sights (v0.4) are the engine's own; a gamemode can hide them and give weapons their own sights.

player.Hud#

long? Money { get; set; }#

The money in the top right. null hides it. When it changes, the player sees a short "+$250" or "-$80".

void SetStrip(int slot, string label, float value, string color = "#4E9CD8") · void ResetStrip(int slot)#

The strips under the radar: slot 0 is health by default, 1 armour, 2 air. Armour and air only show once you set them. value is 0 to 1; color is a hex colour. ResetStrip gives the slot back to the game.

void StartTimer(string id, string label, float seconds, bool countDown = true) · void StopTimer(string id)#

A timer in the top left, counting down from seconds (red in the last 10 seconds) or up from it. Starting a timer with the same id replaces it.

void SetWaypoint(Vector3 target) · void ClearWaypoint()#

The GPS target. The radar draws the route over the game's own road network (car roads while driving, footpaths on foot), re-routes as the player moves, and clears the target when they arrive.

void SetStat(string id, string label, string value) · void ClearStat(string id) (v0.4)#

A stat line in the bottom right, above the area name: SetStat("job", "Job", "Trucker"). Setting the same id again updates the line; the newest line is at the top.

void SetSight(int weaponModelId, string sight) (v0.4)#

Gives a weapon its own sight for this player. weaponModelId is the San Andreas weapon model id (346 pistol, 356 M4, 358 sniper rifle, ...). Sights: HudSight.Dot, Cross, Shotgun, Scope (full-screen, zooms), Launcher, Camera (viewfinder, zooms), Thrown; HudSight.Default gives the weapon its default back.

void Hide(string piece) · void Show(string piece)#

Hides or shows a piece for this player, e.g. during a cutscene. Pieces: HudPiece.Radar, HudPiece.TopRight, HudPiece.BottomRight, HudPiece.Timers, and since v0.4 HudPiece.WeaponWheel, HudPiece.RadioWheel, HudPiece.Phone, HudPiece.Sights.

C#
1player.Hud.Money = 1500;2player.Hud.SetStrip(1, "Armour", 0.75f);3player.Hud.StartTimer("heist", "Get to the van", 90f);4player.Hud.SetWaypoint(vanPosition);5player.Hud.SetStat("job", "Job", "Courier");6player.Hud.SetSight(356, HudSight.Dot); // a red-dot sight on the M4

player.Wanted#

int Level { get; set; }#

0 to 5 stars. Raising it starts the police search around the player's current position.

Vector3 SearchCenter · float SearchRadius#

Where the police are searching and how far out: 150 m at one star, 100 m more per star (550 m at five). The radar shows the area as a flashing red and blue disc.

void Seen()#

The police have seen the player: the search area moves to them and the escape timer restarts. Call it from your own police logic.

Escaping#

The server checks every tick. Once the player has been outside the search area for 6 seconds (PlayerWanted.ClearAfterSeconds), the level drops to 0 and Escaped fires. While they're outside, their stars flash.

event Action Escaped · bool IsOutsideSearchArea · float SecondsOutside#

C#
1player.Wanted.Level = 2;2player.Wanted.Escaped += () =>3{4    player.Toast("You lost the police.", ToastKind.Success);5    player.Hud.Money += 250;6};

A complete example is examples/HudDemo in the Godfather-API repository.