iZone is a zone managment system for FiveM.
It offers utlities to create, manage zone and detecting if a player is in a zone.
It also can trap a player in a zone! what a chance!
Dependency: mysql-async
Download this repo:
git clone https://github.com/izio38/iZone.git
, or click the download button.
Execute zones.sql
on your MySQL server.
Zone creation is explained in the in-game panel.
Citizen.CreateThread(function()
while true do
Wait(100)
TriggerEvent("izone:isPlayerInZone", "zone1", function(isIn)
print(isIn)
end)
end
end)
TriggerEvent("izone:isPlayerInZone", "zone1", cb(val))
-> val can be either false, true or nil. nil if the zone doesn't exist.
Citizen.CreateThread(function()
while true do
Wait(100)
TriggerEvent("izone:isPlayerInCatZone", "foot", "field1", function(isIn)
print(isIn)
end)
end
end)
Citizen.CreateThread(function()
while true do
Wait(100)
TriggerEvent("izone:getAllZonesThePlayerIsIn", function(zones)
print(json.encode(zones))
end)
end
end)
Note: This return {}
if there is no zone. Else the format is:
zones = {
{name = "", cat = "", center = {x = 1, y = 2}, ...},
{name = "", cat = "", center = {x = 1, y = 2}, ...},
{name = "", cat = "", center = {x = 1, y = 2}, ...}
}
I'm not sure about performence tho.
First initiate the trap (it teleport the player in the zone if the player isn't in there already):
TriggerEvent("izone:initiateATrapZone", "zone1")
Then stuck him to the zone (call every tick or every 100 ms, your call):
TriggerEvent("izone:trapPlayerInZone", "zone1")