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

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.

The server also knows client zones, as most players report them. One modified client is outvoted, but a zone only one player has is whatever they say. Use 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.

EventPayload
whip_core:zone:entered{ zoneId, key?, source }
whip_core:zone:exitedThe same, plus dropped = true (left the server inside it) or removed = true (the zone went)

Saved zones

EnsureZone(key, data)SERVERWAITS#

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.

ParamTypeDescription
keystringLetters, digits, _ - . :, at most 60. Refused if another running resource declared it
datatabletype ('box' | 'sphere' | 'poly'), pos, size + heading (box), radius (sphere), points (poly, 3+), minZ, maxZ, label, group, priority, rules, notify, trackVehicles, trackPlayers
Returns: zone, or false, reason
Whip.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)
DeleteZone(keyOrId)SERVERWAITS#

Deletes a saved zone for everyone. Refused for a zone a running resource declares, and for a server zone (use RemoveZone).

ParamTypeDescription
keyOrIdstringKey, or 'dbzone_<n>' id
Returns: true, or false, reason

Server zones

RegisterZone(id, data)SERVER#

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.

ParamTypeDescription
idstringZone id
datatabletype, 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
Returns: true, or false, reason
RemoveZone(id)SERVER#

Removes one of your server zones. A client zone of the same id is separate and stays.

ParamTypeDescription
idstringZone id
Returns: true, or false, reason

Queries

IsPointInZone(id, point, trusted)SERVER#

Whether a point is inside a zone.

ParamTypeDescription
idstringZone id, or a saved zone's key
pointvector3Point to test
trustedboolean?true: only server-held zones answer; a client-made one is false. For anti-cheat
Returns: boolean
if not exports.whip_core:IsPointInZone('mrpd', GetEntityCoords(GetPlayerPed(source)), true) then
    return false, 'You need to be at the station'
end
GetPlayersInZone(id)SERVER#

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.

ParamTypeDescription
idstringZone id, or a saved zone's key
Returns: number[]
GetVehiclesInZone(id)SERVER#

The vehicles inside a zone. vehicleId is nil for a car WHIP doesn't track; entity is always set.

ParamTypeDescription
idstringZone id, or a saved zone's key
Returns: { vehicleId, entity }[]
GetZones()SERVER#

Every zone the server knows, as a list: GetZones()[id] is always nil, so use GetZone.

Returns: { zoneDef, zoneDef, … }
GetZone(id)SERVER#

One zone's definition.

ParamTypeDescription
idstringZone id, or a saved zone's key
Returns: table|nil