World markers
Four kinds of thing your gamemode puts in the world with the same calls (create, update, destroy, listAll,
getById). Each is a WorldMarker:
| Namespace | What it is | Each player sees |
|---|---|---|
textLabels |
3D text in the world, open.mp’s text labels | the nearest 256 |
mapIcons |
An icon on the radar and the map | the nearest 64 |
checkpoints |
One of the game’s checkpoints, with enter and leave events | the nearest 8 |
areas |
A box or sphere, with enter and leave events | the nearest 64 colored boxes on the radar |
None of them replaces players.setRaceCheckpoint: each player has one
race checkpoint, with its own events.
Who sees what
Section titled “Who sees what”A player sees a marker when all of these hold:
- it is
visible; playersis left out,null, or names them;- it is in their
interior, or itsinterioris 13, every interior; - it is in their virtual world, or its
virtualWorldisvirtualWorlds.every; - it is within its
drawDistance(text labels) orrange(map icons, checkpoints), measured from the player; 0 is the whole map; - it is among the nearest of its kind.
It goes again 20 m beyond that distance, so a player on the edge does not see it flicker. The defaults are 30 m for text labels, 200 m for checkpoints and the whole map for map icons. Players who join later, come back, or walk into range all see the same markers. A change reaches them at once.
An area is a box (min, max) or a sphere (position, radius) that the server watches. Nothing happens when a
player comes in unless your gamemode does it: a safe zone, a turf, a shop’s forecourt.
import { areas, screen, server } from "nativemp";
const safe = await areas.create({ min: [1780, -2500, 0], max: [1800, -2480, 50], colorRgba: 0x00FF0060 });
server.on("playerEnteredArea", ({ player, area }) => { if (safe.status === "applied" && area.id === safe.createdId) screen.showGameText("~g~Safe", { player, durationMs: 2000, style: 3 });});A box with a colorRgba also shows on the radar and the map, as gang territory does. visible: false hides that color
and the area keeps sending its events. A sphere never shows.
The server checks areas at each position a player’s game sends, so a car can cross an area thinner than about 6 m without an event. Checkpoints check the whole move: use a checkpoint for a thin line.
Entering and leaving
Section titled “Entering and leaving”playerEnteredCheckpoint,
playerLeftCheckpoint, playerEnteredArea
and playerLeftArea come from where the server saw the player. A player counts as
outside when:
- the marker is not for them, or it is in another interior or virtual world;
- they are dead, busted or held. Dying inside sends a leave event; spawning inside sends an enter event;
- it is a checkpoint and it is not
visible.
A move of up to 150 m that passes through a checkpoint sends both events, a teleport too. A longer one is a teleport,
and only where it ends counts. Destroying a marker or leaving the server sends no leave event: listen to
scriptMarkerDestroyed and
playerDisconnected. These are events, with nothing to cancel, because the
markers do nothing by themselves. Change who sees one with visible and players.
Lifetime
Section titled “Lifetime”| When | What happens |
|---|---|
| Your gamemode stops or reloads | Every marker goes, for everyone. |
| One of several players it is for leaves | They are taken off it: scriptMarkerUpdated. |
| The last player it is for leaves | It is destroyed: scriptMarkerDestroyed. |
| That player comes back | It stays gone: a new connection is a new player. Make it again in playerConnected or playerSpawned. |
| A player leaves a marker that is for everyone | Nothing: it stays. |
Limits
Section titled “Limits”The server keeps up to 4,096 markers of all kinds, at most 1,024 of them checkpoints and areas. A text label is one line of up to 128 bytes, and cannot follow a player or a vehicle. The 8 checkpoints a player sees share the game’s 32 checkpoint slots; the 64 map icons share the radar’s 175 with player and vehicle markers, and an icon waits while the radar is full.