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
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.
| Field | Type | Description |
|---|---|---|
| type | string | 'box', 'sphere' or 'poly' |
| pos, size, heading | vector3, vector3, number | A box: its centre, size and heading |
| pos, radius | vector3, number | A sphere |
| points, minZ, maxZ | vec2[], number, number | A poly: its outline and heights |
| the rest | any | id, onEnter, onExit, inside, condition, priority, group, label, debug, rules, notify, weather, trackVehicles, onVehicleEnter, onVehicleExit |
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 })
Deletes one of your zones (another resource's is refused), firing onExit if the player was inside.
| Param | Type | Description |
|---|---|---|
| id | string | Zone id |
true, or false, whyDeletes all your zones in a group; other resources' stay.
| Param | Type | Description |
|---|---|---|
| group | string | Group name |
true, count, or false, whyWhere the player is
These take a zone id or a saved zone's key.
Whether a point is inside a zone: instant maths, no polling.
| Param | Type | Description |
|---|---|---|
| id | string | Zone id or key |
| point | vector3 | Point to test |
booleanWhether the local player is inside, as of the last poll.
| Param | Type | Description |
|---|---|---|
| id | string | Zone id or key |
booleanEvery zone id the local player is inside.
string[]Every zone within a radius of a point, nearest first.
| Param | Type | Description |
|---|---|---|
| pos | vector3 | Centre |
| radius | number | Metres (default 50) |
{ id, type, label, pos, dist }[]A zone as the client holds it: shape, size, rules, label, priority, inside, debug and hasCondition (the function itself isn't returned).
| Param | Type | Description |
|---|---|---|
| id | string | Zone id |
table|nilChanging a zone#
Changes one of your zones: only the keys in patch. A key it doesn't know is refused and nothing changes.
| Key | Type | Description |
|---|---|---|
| pos | vector3 | Moves the zone (a poly's points move with it) |
| size | number | vector3 | A sphere's radius, or a box's dimensions. A poly is resized by its points |
| rules | table|false | Replaces the rules; false for none. To turn one rule off, send the rules without it |
| condition | function|false | () → boolean: while it returns false, the player counts as outside (rules off, no events). false takes it off |
| label | string | The name shown on entry |
| priority | number | Where 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 |
| notify | boolean | The on-screen enter and exit notice; events fire either way |
| trackVehicles | boolean | Tests the player's vehicle position instead of the ped's, which at speed can skip over a thin zone |
| debug | boolean | Draws the outline every frame. For development only |
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 } })