Zone tracking for the local player: enter, exit and inside callbacks over the shapes in fivem.shared.colshape.

Zones.add(new Circle(shopPoint, 2.0, 3.0), {
    onEnter: _ -> Ui.showHelp("Press ~INPUT_CONTEXT~ to shop"),
    onExit: _ -> closeShopPrompt()
});

Every zone is polled from a single shared thread rather than one thread each, so registering a hundred zones costs one loop, not a hundred. The poll runs at pollIntervalMs (200 ms by default) and each shape is rejected by a cheap bounding-sphere test before its real containment test runs.

Zones live for as long as the resource does. Remove them on stop if the handlers touch anything that needs cleaning up.

Static variables

@:value(false)staticdebugDraw:Bool = false

Draws every registered shape in the world. For development only.

@:value(200)staticpollIntervalMs:Int = 200

How often the player's position is checked against every zone.

200 ms is imperceptible for walking and cheap enough to ignore. Lower it if players routinely cross zone boundaries at speed — a car at 100 km/h covers 5.5 metres between polls.

Static methods

staticadd(shape:ColShape, options:ZoneOptions):Zone

Registers a shape and starts watching it.

@:value({ heading : 0 })staticaddBox(center:Vector3, size:Vector3, options:ZoneOptions, heading:Float = 0):Zone

Convenience for an oriented box.

@:value({ height : 0 })staticaddCircle(center:Vector3, radius:Float, options:ZoneOptions, height:Float = 0):Zone

Convenience for the most common shape: a cylinder around a point.

staticaddSphere(center:Vector3, radius:Float, options:ZoneOptions):Zone

Convenience for a sphere, where height genuinely matters.

staticall():Array<Zone>

Every registered zone.

staticclear():Void

Removes every zone. Worth calling from a resource stop handler.

staticinside():Array<Zone>

Every zone the player is currently standing in.

staticremove(zone:Zone):Void