fivemzonesluasafezonegameplay
Zone-Based Systems in FiveM — Create Immersive Areas
March 22, 2026
1 min read
4 views
Zone-Based Systems in FiveM
Zone detection is at the heart of many gameplay mechanics in FiveM, whether it be safe zones, job areas or restricted areas.
Basic method: GetDistanceBetweenCoords
local zoneCenter = vector3(100.0, 200.0, 30.0)
local zoneRadius = 50.0
Citizen.CreateThread(function()
while true do
local playerCoords = GetEntityCoords(PlayerPedId())
local distance = GetDistanceBetweenCoords(playerCoords, zoneCenter, true)
if distance <= zoneRadius then
DrawText3D(zoneCenter.x, zoneCenter.y, zoneCenter.z + 1.0, "~y~Safe Zone")
end
Citizen.Wait(500)
end
end)
M2.SafeZone Configuration
Config.Zones = {
{
name = "Legion Square Safe Zone",
coords = vector3(195.17, -933.77, 30.69),
radius = 100.0,
blip = {
sprite = 1,
color = 2,
scale = 0.8,
label = "Safe Zone"
}
},
{
name = "Hospital Safe Zone",
coords = vector3(1839.56, 3672.87, 34.28),
radius = 80.0,
blip = { sprite = 61, color = 49, scale = 0.9, label = "Hospital" }
}
}
ESX.Point — Zone at Smart
local point = ESX.Points.add(
vector3(441.7, -986.8, 30.7),
5.0,
function() -- onEnter
exports['M2.Notify']:Notify('info', 'Press E to execute', 5000)
end,
function() -- onExit
exports['M2.Notify']:Notify('info', 'Exit workspace', 3000)
end,
function() -- onTick
DrawText3D(441.7, -986.8, 31.7, "[E] - Start")
if IsControlJustReleased(0, 38) then
TriggerServerEvent('myJob:startWork')
end
end
)
Performance Tip
-- Don't use Wait(0) if not necessary.
-- Use dynamic wait instead.
Citizen.CreateThread(function()
while true do
local coords = GetEntityCoords(PlayerPedId())
local nearZone = IsNearAnyZone(coords)
Citizen.Wait(nearZone and 100 or 1000) -- Near the zone, check frequently, far away, check for a long time.
end
end)
Summary
Zone-based systems are the building blocks of FiveM gameplay, starting with radius-based detection, using ESX.Points for interaction, and M2.SafeZone for safe areas.
Related Articles
Breaking: GTA Online อัพเดท "Money Fronts" — FiveM Server Owners ต้องทำอะไร?
Rockstar ปล่อย GTA Online อัพเดท Money Fronts มีผลกระทบต่อ FiveM servers บางส่วน นี่คือสิ่งที่ต้องทำทันทีหลังอัพเดท
Community Spotlight: Script และ Projects ที่น่าสนใจจาก FiveM Community
รวม scripts, tools และ projects ที่โดดเด่นจาก FiveM community ในช่วงที่ผ่านมา ตั้งแต่ free resources ถึง open-source projects
txAdmin อัพเดทใหม่ — Dashboard, Diagnostics และ Ban System ที่ดีขึ้น
txAdmin ซึ่งตอนนี้เป็นส่วนหนึ่งของ Cfx.re อย่างเป็นทางการ ได้รับการอัพเดทครั้งใหญ่ มี features ใหม่ที่ทำให้ Server Management ง่ายขึ้นมาก