Zones API (server)
The server holds saved zones (EnsureZone and the Zone Editor, synced to every client) and server zones a resource registers with RegisterZone. Every lookup takes a saved zone's key as well as its 'dbzone_<n>' id. New to zones? Read Zones.
EnsureZone or RegisterZone for a zone the server must trust, and trusted = true on IsPointInZone. A client zone id needs letters, digits, _ and -, 60 at most, to reach the server.Server events#
Give a zone of either kind trackPlayers = true and the server checks it every Config.ZoneTrackInterval ms (1000), firing local server events. A player in the character creator or logging out is in no zone; one in another routing bucket still counts.
| Event | Payload |
|---|---|
whip_core:zone:entered | { zoneId, key?, source } |
whip_core:zone:exited | The same, plus dropped = true (left the server inside it) or removed = true (the zone went) |
Saved zones
A saved zone declared by your key; declare it in Whip.register, so it runs at every start. It's made once and updated only when your declaration changes, so an admin's edits stand until then. A different type makes a new zone under the key.
| Param | Type | Description |
|---|---|---|
| key | string | Letters, digits, _ - . :, at most 60. Refused if another running resource declared it |
| data | table | type ('box' | 'sphere' | 'poly'), pos, size + heading (box), radius (sphere), points (poly, 3+), minZ, maxZ, label, group, priority, rules, notify, trackVehicles, trackPlayers |
zone, or false, reasonWhip.register(function()
Whip.core:EnsureZone('mrpd', {
type = 'box', pos = vector3(441.0, -982.0, 30.7), size = vector3(60, 50, 20), heading = 0,
label = 'Mission Row PD', trackPlayers = true,
})
end)
Deletes a saved zone for everyone. Refused for a zone a running resource declares, and for a server zone (use RemoveZone).
| Param | Type | Description |
|---|---|---|
| keyOrId | string | Key, or 'dbzone_<n>' id |
true, or false, reasonServer zones
Registers a zone for server-side checks, with no tick unless trackPlayers. The id is yours (the registration rule), and your zones go when your resource stops. A bad shape is refused, saying what's wrong.
| Param | Type | Description |
|---|---|---|
| id | string | Zone id |
| data | table | type, pos, size, heading, radius, points, minZ, maxZ, group, label, trackPlayers, tag (for ReleaseTag). A sphere needs pos + radius, a box pos + size, a poly 3+ points |
true, or false, reasonRemoves one of your server zones. A client zone of the same id is separate and stays.
| Param | Type | Description |
|---|---|---|
| id | string | Zone id |
true, or false, reasonQueries
Whether a point is inside a zone.
| Param | Type | Description |
|---|---|---|
| id | string | Zone id, or a saved zone's key |
| point | vector3 | Point to test |
| trusted | boolean? | true: only server-held zones answer; a client-made one is false. For anti-cheat |
booleanif not exports.whip_core:IsPointInZone('mrpd', GetEntityCoords(GetPlayerPed(source)), true) then
return false, 'You need to be at the station'
end
The server ids of every player inside a zone. It tests every player: to react as they come and go, use trackPlayers instead of a loop. Players in the character creator or logging out are left out; routing buckets don't matter.
| Param | Type | Description |
|---|---|---|
| id | string | Zone id, or a saved zone's key |
number[]The vehicles inside a zone. vehicleId is nil for a car WHIP doesn't track; entity is always set.
| Param | Type | Description |
|---|---|---|
| id | string | Zone id, or a saved zone's key |
{ vehicleId, entity }[]Every zone the server knows, as a list: GetZones()[id] is always nil, so use GetZone.
{ zoneDef, zoneDef, … }One zone's definition.
| Param | Type | Description |
|---|---|---|
| id | string | Zone id, or a saved zone's key |
table|nil