Skip to content

Server API

Everything gamemodes use comes from @sagl/server:

import {
  Server, Player, Vehicle, Ped, Zone, Garage, World, CullZone, GameMap,
  ClientScripts, Channel, Console,
  Weapon, Stat, BodyPart, Color, RadioStation, Weather, GarageType,
  ZoneAttribute, AudioZone, DoorDamage, TyreDamage, PanelDamage,
} from "@sagl/server";

Each page lists a class's properties, then every method and event in detail: its signature, what each parameter is, what it returns or throws, and an example of using it.

Class What it is
Server The server: options, players, vehicles, peds, zones, worlds, time.
Signing in Players start the game with a token (--token); your middleware checks it and lets them in with a name, account id and metadata, or turns them away.
Query What anyone can learn without joining (server lists, websites): players, branding, links, values; UDP and HTTP, and @sagl/query.
Events Everything server.on() can listen to.
Player A connected player.
Vehicle A vehicle, yours or the ambient traffic's.
Ped An NPC, yours or the ambient population's.
World and CullZone A virtual world's time, weather and population; interior effect zones.
Zone and Garage Watched areas; the game's garages.
GameMap Markers and overlays on the pause menu's map.
ScreenDraw Text, boxes and images drawn on screen, SA-MP textdraw style.
Game text gxt(): the game's own text by key, in each player's game.
Custom animations Your own animation files (IFP), played like the game's; GTA III / VC conversion.
ServerAudio Sounds from client files, positioned in the world or not.
Chat and commands The chat, and commands built as Minecraft's (arguments, subcommands, suggestions).
Interactions Vending machines, payphones, anything players walk up to and use.
Effects The game's particle effects (fire, smoke, explosions, wood chips) and coloured dust.
Objects, pickups and labels The server's objects (crates, gates: moved and broken by the server), pickups and floating text.
Missions Missions: parties, start markers, sections and catch-up, waits, fail conditions, rewards, cooldowns.
Paint finishes Cars' paint drawn with shaders: metallic flake, or your own.
Markdown and documents Help pages, rules and terms of service in markdown: a document viewer with buttons, and markdown in chat, dialogs and your own UI, with players' keys as icons.
Camera Players' cameras: shots, glides, sequences, smoothed paths, a freecam, field of view and roll.
Screen effects Your own pixel shaders over players' screens: grading, night vision, drunk, flashbacks.
Pay 'n' Spray and mod shops The game's resprays and mod shops, run by the server: on by default, with options.
PlayerUi UI documents (RML layouts) the server opens on a player's screen and hears back from.
PlayerHud One player's mission HUD: blips, objective text, timers, result screens.
ClientScripts and Channel Client scripts, and talking to them.
Console The operator console.
Constants Weapon, Stat, Weather, ...

Geometry

distance(a, b), distance2d(a, b) (on the map, ignoring height), headingVector(heading) (the way a heading points), headingTo(from, to) and along(at, heading, metres, up?), imported from @sagl/server, with headings in the game's degrees (0 north, anticlockwise).

Conventions

  • Positions are metres in world coordinates: { x, y, z } (Vector3).
  • Headings are degrees, 0 north, increasing anticlockwise.
  • Colours for messages are 0xRRGGBB; for the map and branding 0xRRGGBBAA or "#RRGGBB[AA]".
  • Getters read the server's latest state (synced ~20 times a second); setters change it for everyone.
  • Every Player, Vehicle, Ped and Zone has data, a free-form object for your own state.