Esc to clear, Enter to open the best match, click an export to open it in its page
World

Zones API (client)

Client exports to make zones, ask where the player is and change a zone's rules. New to zones? Read Zones.

Making and removing zones

RegisterZone(data)CLIENT#

Makes a zone: type is 'box', 'sphere' or 'poly'. Give it an id (letters, digits, _ and -, 60 at most): the same id again replaces it, and the server only learns of a zone with an id like that.

FieldTypeDescription
typestring'box', 'sphere' or 'poly'
pos, size, headingvector3, vector3, numberA box: its centre, size and heading
pos, radiusvector3, numberA sphere
points, minZ, maxZvec2[], number, numberA poly: its outline and heights
the restanyid, onEnter, onExit, inside, condition, priority, group, label, debug, rules, notify, weather, trackVehicles, onVehicleEnter, onVehicleExit
Returns: string zone id, or false, why (no type, or the id is another resource's)
local id = exports.whip_core:RegisterZone({ type = 'sphere', pos = vec3(200, -800, 30), radius = 8.0,
    onEnter = function(zone) end })
RemoveZone(id)CLIENT#

Deletes one of your zones (another resource's is refused), firing onExit if the player was inside.

ParamTypeDescription
idstringZone id
Returns: true, or false, why
RemoveZoneGroup(group)CLIENT#

Deletes all your zones in a group; other resources' stay.

ParamTypeDescription
groupstringGroup name
Returns: true, count, or false, why

Where the player is

These take a zone id or a saved zone's key.

IsPointInZone(id, point)CLIENT#

Whether a point is inside a zone: instant maths, no polling.

ParamTypeDescription
idstringZone id or key
pointvector3Point to test
Returns: boolean
IsInZone(id)CLIENT#

Whether the local player is inside, as of the last poll.

ParamTypeDescription
idstringZone id or key
Returns: boolean
GetZonesInside()CLIENT#

Every zone id the local player is inside.

Returns: string[]
GetZonesNearby(pos, radius)CLIENT#

Every zone within a radius of a point, nearest first.

ParamTypeDescription
posvector3Centre
radiusnumberMetres (default 50)
Returns: { id, type, label, pos, dist }[]
GetZone(id)CLIENT#

A zone as the client holds it: shape, size, rules, label, priority, inside, debug and hasCondition (the function itself isn't returned).

ParamTypeDescription
idstringZone id
Returns: table|nil

Changing a zone#

UpdateZone(id, patch)CLIENT#

Changes one of your zones: only the keys in patch. A key it doesn't know is refused and nothing changes.

KeyTypeDescription
posvector3Moves the zone (a poly's points move with it)
sizenumber | vector3A sphere's radius, or a box's dimensions. A poly is resized by its points
rulestable|falseReplaces the rules; false for none. To turn one rule off, send the rules without it
conditionfunction|false() → boolean: while it returns false, the player counts as outside (rules off, no events). false takes it off
labelstringThe name shown on entry
prioritynumberWhere zones overlap, all their rules apply; priority settles only the speed limit (highest priority that sets one; ties take the lower), the weather layer, and callback order (enters highest first, exits lowest first). A car park's 20 km/h inside a district's 60 needs the higher priority
notifybooleanThe on-screen enter and exit notice; events fire either way
trackVehiclesbooleanTests the player's vehicle position instead of the ped's, which at speed can skip over a thin zone
debugbooleanDraws the outline every frame. For development only
Returns: true, or false, why ('no zone "x"', 'zone "x" belongs to …', a size its shape doesn't take)
exports.whip_core:UpdateZone('myres_station', { label = 'Closed', rules = { noWeapons = true } })