Zones
A zone is an area of the world (a box, sphere or polygon) that knows when players enter and leave, and can enforce rules inside with no code of your own.
Making a zone
On the client, make one with RegisterZone: a 'box', a 'sphere' or a 'poly' (an outline with a min and max Z). The client checks its zones every Config.ZonePollInterval (300 ms). A zone every player shares, or the server must trust, is declared on the server with EnsureZone or drawn in the Zone Editor; it's saved, and you use its key everywhere (require = { zone = 'mrpd' } on an action).
-- Client, in Whip.register: a safe zone
exports.whip_core:RegisterZone({
type = 'box', id = 'myres_station', pos = vec3(440, -980, 30), size = vec3(20, 20, 10),
label = 'Police Station', group = 'police', notify = true,
rules = { noPvP = true, noWeapons = true, heal = true },
onEnter = function(zone) end,
onExit = function(zone) end,
})Rules#
| Rule | Type | Inside the zone |
|---|---|---|
noWeapons | bool | Weapons removed on entry, re-equipping blocked |
noPvP | bool | The player can't be hurt, fire or melee |
noMelee | bool | No punching or melee |
disableFiring | bool | No firing; carrying is fine |
speedLimit | number | Vehicle speed cap (km/h) |
noVehicles | bool | Out of the vehicle on entry: by the door, or bailing out of one that moves. Not a player the seat engine holds in their seat (HoldInSeat) |
heal, healRate | bool, number | Gradual health regen, HP per tick (default 2) |
noWantedLevel | bool | Wanted level cleared and prevented |
noCollision | bool | No ped-to-ped collision |
noFallDamage | bool | No fall damage; the player is collision-proof, so crashes and being run over do none either |
jobWhitelist, aceWhitelist, charWhitelist | table, string, table | Who's authorised; meeting any one is enough |
ejectUnauthorized | bool | Teleports unauthorised players out |
Events
Any client resource hears the local player cross any zone. On the server, give a zone trackPlayers = true and listen for the server events of the same names.
AddEventHandler('whip_core:zone:entered', function(zone)
if zone.group == 'police' then --[[ zone.zoneId, zone.label ]] end
end)
AddEventHandler('whip_core:zone:exited', function(zone) end)The Zone EditorServer owners#
/whip → World → Zones → Open the editor gives you a free camera: 1 / 2 / 3 draw a box, sphere or poly, scroll sizes it.
- Room scanner. Inside a room, press H and fly: WHIP traces the walls, smoothing over doorways and windows. H previews, scroll sets height, G confirms.
- Vertex editor. 4 moves a poly's points and 5 sets each point's own height (E grabs, G confirms, Esc reverts), so one zone can cover a garage lower than the house.