areas.create
Marks out a box or a sphere in the world: a safe zone, a gang’s turf, a shop’s forecourt. The server sends
playerEnteredArea and playerLeftArea;
nothing else happens unless your gamemode does it. A box with a color also shows on the radar and the map, as gang
territory does. Each player sees the nearest 64 of those.
Renamed in 0.28 from zones.create; see renamed names.
Signature
Section titled “Signature”areas.create(settings: AreaSettings): Promise<ActionResult>Parameters
Section titled “Parameters”| Name | Type | Description |
|---|---|---|
settings.min, settings.max |
Vector3 |
A box: its two corners, each axis of min below max’s. |
settings.position, settings.radius |
Vector3, number |
Or a sphere: its centre and its radius in metres, up to 1000. |
settings.colorRgba |
number |
Optional. A box’s color on the radar and the map, 0xRRGGBBAA. Defaults to 0, none. A sphere never shows. |
settings.interior |
number |
Optional. The interior it is in: 0 outside (the default), 1 to 18 an interior’s, 13 every interior. |
settings.virtualWorld |
number |
Optional. The virtual world it is in (default 0), or virtualWorlds.every for every one. |
settings.visible |
boolean |
Optional. false hides a box’s color on the radar; the area still sends its events. Defaults to true. |
settings.players |
PlayerTarget[] | null |
Optional. Only these players see it, while they are connected. Left out or null: everyone. |
Returns
Section titled “Returns”A promise of an ActionResult: applied with the new area’s ID in createdId, or
rejected with invalid-zone, invalid-area, invalid-world, invalid-colour, invalid-value or invalid-players. A player in players who has left gives player-not-found. The server keeps up to
4,096 text labels, map icons, checkpoints and areas together, at most 1,024 of them checkpoints and areas
(host-marker-limit when full).
Players who join later, or come back, see it too. One for chosen players is destroyed when the last of them
leaves: make it again when they come back. All of them go when your gamemode stops or reloads.
Example
Section titled “Example”import { areas, server } from "nativemp";
const result = await areas.create({ min: [1780, -2500, 0], max: [1800, -2480, 50], colorRgba: 0x00FF0060 });if (result.status === "applied") server.log(`Area ${result.createdId} is up`);Related
Section titled “Related”areas.update: change itareas.destroy: remove itareas.listAll: all of themArea: the record and its settings- World markers: who sees what, and when the events come