Just something like this… am on my phone so it might not be good but test
local isInArea = false
local area = { x = 1.0, y = 1.0, z = 1.0, radius = 10.0 }
Citizen.CreateThread(function()
while true do
Citizen.Wait(0)
local playerPed = GetPlayerPed(-1)
local pedX, pedY, pedZ = table.unpack(GetEntityCoords(playerPed, true))
for i=1, #area, 1 do
area = area[i]
if (Vdist2(area.x, area.y, area.z, pedX, pedY, pedZ) <= area.radius and isInArea == false) then
--spawn zombies
TriggerEvent('yourevent')
isInArea = true
elseif (Vdist2(area.x, area.y, area.z, pedX, pedY, pedZ) > area.radius and isInArea == true) then
--stop zombies
TriggerEvent('yourotherevent')
isInArea = false
end
end
end
end)