Skip to content

The sagl API

Everything is on the global sagl object.

Channels

sagl.on(channel, handler) handler(data) for what the gamemode sends on channel (parsed JSON).
sagl.off(channel, handler?) Removes that handler, or all of the channel's.
sagl.emit(channel, data?) Sends data (JSON) to the gamemode: server.channel(channel).on(...) and the clientMessage event. Channels are 1-64 characters.

Logging

sagl.log(...values) writes to the player's sagl/sagl.log, as script: ....

Timers

The usual: setTimeout(fn, ms), setInterval(fn, ms), clearTimeout(id), clearInterval(id). Promises and async functions work too.

The local player

sagl.player.id Their player id (as the server knows it).
sagl.player.position() { x, y, z }.
sagl.player.heading() Degrees.
sagl.player.health()
sagl.player.armour()
sagl.player.inVehicle()

Branding

sagl.branding: the server's branding, as { name, primary, secondary, logo } (colours as "#rrggbb" or null, logo a URL for RML or null).

UI, the map, files