Skip to content

textLabels.create

Puts a line of text at a place in the world, in the font of the players’ name tags: a shop’s name, a door’s price, a rule at a spawn. Each player sees the nearest 256 within its drawDistance. A text label cannot follow a player or a vehicle.

Renamed in 0.28 from labels.create; see renamed names.

textLabels.create(settings: TextLabelSettings): Promise<ActionResult>
Name Type Description
settings.text string One line, up to 128 bytes of UTF-8, without control characters.
settings.position Vector3 Where it stands, [x, y, z].
settings.colorRgba number Optional. Its color, 0xRRGGBBAA. Defaults to white.
settings.drawDistance number Optional. How near a player must be to see it, in metres, up to 6000. Defaults to 30; 0 is the whole map.
settings.testLineOfSight boolean Optional. true hides it behind buildings. Defaults to false.
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 it from everyone. Defaults to true.
settings.players PlayerTarget[] | null Optional. Only these players see it, while they are connected. Left out or null: everyone.

A promise of an ActionResult: applied with the new text label’s ID in createdId, or rejected with invalid-text, invalid-position, invalid-range, 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.

gamemodes/my-mode.ts
import { server, textLabels } from "nativemp";
const result = await textLabels.create({ text: "Pay 'n' Spray", position: [2063, -1831, 14], colorRgba: 0xFFCC00FF, drawDistance: 40 });
if (result.status === "applied") server.log(`Text label ${result.createdId} is up`);