TextLabel
Defined in: server/api.d.ts:2381
Text floating in the world on every player’s screen, as FiveM resources draw 3D text: over a shop’s door, a ped’s head, a player. A player sees it while they are in its worldspace or interior and within its range. A label outlives the resource that made it until destroyed. Move it with setPosition or attachTo, not by setting position.
Extends
Section titled “Extends”Constructors
Section titled “Constructors”Constructor
Section titled “Constructor”new TextLabel(
id):TextLabel
Defined in: server/api.d.ts:2386
Wraps the label with this ID; it creates nothing.
Parameters
Section titled “Parameters”number
Network entity identifier.
Returns
Section titled “Returns”TextLabel
Inherited from
Section titled “Inherited from”Methods
Section titled “Methods”attachTo()
Section titled “attachTo()”attachTo(
target):boolean
Defined in: server/api.d.ts:2432
Has the label float over a player or an NPC: each player’s game draws it over that body while it has it loaded, and over where the server last saw it otherwise.
Parameters
Section titled “Parameters”target
Section titled “target”Whose body to float over; null to stay where it is.
Returns
Section titled “Returns”boolean
False once it is gone.
destroy()
Section titled “destroy()”destroy():
boolean
Defined in: server/api.d.ts:2397
Takes the label off every player’s screen.
Returns
Section titled “Returns”boolean
False once it is gone.
setColor()
Section titled “setColor()”setColor(
color):boolean
Defined in: server/api.d.ts:2417
Changes the text’s color.
Parameters
Section titled “Parameters”number
0xRRGGBBAA: 0xFFFFFFFF is opaque white.
Returns
Section titled “Returns”boolean
False once it is gone.
setPosition()
Section titled “setPosition()”setPosition(
position,space?):boolean
Defined in: server/api.d.ts:2425
Moves the label to a point; it stops floating over anyone.
Parameters
Section titled “Parameters”position
Section titled “position”Where, in world units.
space?
Section titled “space?”{ worldSpace: number; } | { interiorCell: number; }
Where that is; its current space when left out.
Returns
Section titled “Returns”boolean
False once it is gone.
setText()
Section titled “setText()”setText(
text):boolean
Defined in: server/api.d.ts:2410
Changes what the label says.
Parameters
Section titled “Parameters”string
Up to 127 bytes of UTF-8; a line break starts a new line.
Returns
Section titled “Returns”boolean
False once it is gone.
setVirtualWorld()
Section titled “setVirtualWorld()”setVirtualWorld(
world):void
Defined in: server/api.d.ts:4292
Moves this entity into another virtual world.
Parameters
Section titled “Parameters”number
Virtual-world identifier used to partition replication and visibility.
Returns
Section titled “Returns”void
Inherited from
Section titled “Inherited from”setVisibleTo()
Section titled “setVisibleTo()”setVisibleTo(
player):void
Defined in: server/api.d.ts:4298
Restricts replication of this entity to one owning connection while preserving normal range and visibility checks.
Parameters
Section titled “Parameters”player
Section titled “player”Entity | null
Player-owned entity whose connection should exclusively receive this entity, or null to clear the restriction.
Returns
Section titled “Returns”void
Inherited from
Section titled “Inherited from”toString()
Section titled “toString()”toString():
string
Defined in: server/api.d.ts:2403
Formats this handle for logging.
Returns
Section titled “Returns”string
The label’s network ID and text.
Inherited from
Section titled “Inherited from”
staticall():TextLabel[]
Defined in: server/api.d.ts:2445
Every label.
Returns
Section titled “Returns”TextLabel[]
One handle per label.
create()
Section titled “create()”
staticcreate(options):TextLabel|null
Defined in: server/api.d.ts:2439
Puts floating text in the world for every player, as FiveM’s DrawText3D is drawn: “[E] Shop” over a counter, a name over a head.
Parameters
Section titled “Parameters”options
Section titled “options”text: what it says. position or entity: where it is or whom it floats over. height: how far above, 140 over a body and 0 at a point by default. color: 0xRRGGBBAA, white by default. range: how far from a player it is drawn, 1000 by default, at most 20000. space: a point’s worldspace or interior, the Commonwealth when left out. player: the one player who sees it, everyone when left out.
color?
Section titled “color?”number
entity?
Section titled “entity?”height?
Section titled “height?”number
player?
Section titled “player?”position?
Section titled “position?”range?
Section titled “range?”number
space?
Section titled “space?”{ worldSpace: number; } | { interiorCell: number; }
string
Returns
Section titled “Returns”TextLabel | null
The label; null when it could not be made. Throws for options without text, or naming neither a position nor a body.
Properties
Section titled “Properties”
readonlyid:number
Defined in: server/api.d.ts:4260
Immutable network entity identifier.
Inherited from
Section titled “Inherited from”position
Section titled “position”position:
Vector3
Defined in: server/api.d.ts:4270
Authoritative world-space position; assignment forces replicated state.
Inherited from
Section titled “Inherited from”rotation
Section titled “rotation”rotation:
Vector3|Quaternion
Defined in: server/api.d.ts:4275
Authoritative rotation; reads return a quaternion and assignments accept a quaternion or Euler angles in degrees.
Inherited from
Section titled “Inherited from”
readonlystate:StateBag
Defined in: server/api.d.ts:4280
Arbitrary key/value state carried by this entity. The server writes it and every client that can see the entity receives it; see StateBag.
Inherited from
Section titled “Inherited from”
readonlytext:string
Defined in: server/api.d.ts:2391
What it says; empty once it is gone.
virtualWorld
Section titled “virtualWorld”
readonlyvirtualWorld:number
Defined in: server/api.d.ts:4265
Current virtual-world identifier.