Zone
constZone:object
Defined in: server/api.d.ts:2036
Areas of the world the server watches, as FiveM resources do with PolyZone: an upright cylinder, around a point in a worldspace or an interior. zoneEnter and zoneLeave tell scripts who came in and who went out, from the places players’ games report: a safe zone, a shop’s floor, a job’s drop point. The server alone knows of them.
Type Declaration
Section titled “Type Declaration”all():
number[]
Every zone’s ID.
Returns
Section titled “Returns”number[]
In the order they were made.
contains()
Section titled “contains()”contains(
zone,position,space?):boolean
Whether a point lies in an area: where an NPC stands, a drop, a spawn.
Parameters
Section titled “Parameters”number
The zone’s ID, as create gave it.
position
Section titled “position”The point.
space?
Section titled “space?”{ worldSpace: number; } | { interiorCell: number; }
Where the point is; the Commonwealth when left out.
Returns
Section titled “Returns”boolean
False for an unknown ID.
create()
Section titled “create()”create(
options):number
Starts watching an area. Players already in it are told so at the next update.
Parameters
Section titled “Parameters”options
Section titled “options”center and radius, on the ground plane, in game units. height: how far above and below the center it reaches, no limit when left out. name: given back with its events. space: its worldspace or interior, the Commonwealth when left out.
center
Section titled “center”height?
Section titled “height?”number
string
radius
Section titled “radius”number
space?
Section titled “space?”{ worldSpace: number; } | { interiorCell: number; }
Returns
Section titled “Returns”number
The zone’s ID. Throws for a missing center or a radius that is not above 0.
getPlayers()
Section titled “getPlayers()”getPlayers(
zone):Player[]
The players in an area, as the last update found them.
Parameters
Section titled “Parameters”number
The zone’s ID, as create gave it.
Returns
Section titled “Returns”Player[]
Empty for an unknown ID.
remove()
Section titled “remove()”remove(
zone):boolean
Stops watching an area; the players in it are told they left.
Parameters
Section titled “Parameters”number
The zone’s ID, as create gave it.
Returns
Section titled “Returns”boolean
False for an unknown ID.