players.setRaceCheckpoint
Gives a player a race checkpoint, or everyone one: GTA:SA’s own race checkpoint, the red tube with an arrow to the next one, the finish flag, or a ring for air races, with a red blip on the radar. Each player has one race checkpoint; a new one replaces the last.
The server sees the player come in, a fast car passing one between two position updates included, and sends
playerEnteredRaceCheckpoint. Set the next checkpoint there.
Signature
Section titled “Signature”players.setRaceCheckpoint(player: PlayerTarget, settings: RaceCheckpointSettings): Promise<ActionResult>Parameters
Section titled “Parameters”| Name | Type | Description |
|---|---|---|
player |
PlayerTarget |
The player, or their ID; 0 for everyone. |
settings.position |
Vector3 |
Where the checkpoint stands. |
settings.nextPosition |
Vector3 |
Optional. Where the arrow points: the next checkpoint. |
settings.checkpointType |
number |
Optional. GTA:SA’s checkpoint type, 0 to 8; see below. Defaults to 0. |
settings.size |
number |
Optional. Its size: its radius in metres, up to 100. Defaults to 8. |
Returns
Section titled “Returns”An ActionResult: applied, or rejected with invalid-position, invalid-checkpoint
or player-not-found.
Example
Section titled “Example”import { players, server, type Vector3 } from "nativemp";
const course: Vector3[] = [[1780, -2490, 13.5], [1810, -2490, 13.5], [1840, -2490, 13.5]];const reached = new Map<number, number>();
function next(player: number, index: number) { const last = index === course.length - 1; return players.setRaceCheckpoint(player, { position: course[index], nextPosition: course[index + 1], checkpointType: last ? 1 : 0 });}
server.on("playerSpawned", ({ player }) => { reached.set(player.id, 0); void next(player.id, 0); });server.on("playerEnteredRaceCheckpoint", ({ player }) => { const index = (reached.get(player.id) ?? 0) + 1; if (index === course.length) return players.clearRaceCheckpoint(player); reached.set(player.id, index); return next(player.id, index);});| Type | Looks |
|---|---|
| 0 | A tube with an arrow towards nextPosition |
| 1 | A tube with the finish flag |
| 2 | A plain tube |
| 3 | An air race ring |
| 4 | An air race finish ring |
| 5 | A ring that turns |
| 6 | A ring that shrinks and goes |
| 7 | A ring that swings down and up |
| 8 | A ring that swings up and down |
A ground checkpoint (0-2) counts as entered within its radius and 10 m up or down; a ring (3-8) within its radius in every direction.
Related
Section titled “Related”players.clearRaceCheckpoint: take it awayplayerEnteredRaceCheckpointandplayerLeftRaceCheckpointcheckpoints.create: several checkpoints at once, for everyone or chosen players
A captured Player keeps this effect bound to its connection across awaits; see Async handlers.