iZone is a zone managment system for FiveM.
It offers utlities to create, manage zone, detect if a player is in a zone and offer the possibility to trap the player in a zone.
Dependency: mysql-async
Download this repo:
git clone https://github.com/izio38/iZone.git
, or click the download button.
If you have any issue with the cursor not disappearing: Make sure to name the resource: izone
.
Execute zones.sql
on your MySQL server.
Open up the config.lua
file:
USE_ESSENTIALMODE_ADMIN_SYSTEM
: if true, it'll use the essentialmode admin system.ESSENTIALMODE_PERMISSION_LEVEL_REQUIRED
: the minimum permission level to create and manage zones.ADMINS
: a list of identifiers to allow iZone uses.CONTROL_TO_OPEN_PANEL
,CONTROL_TO_ADD_POINT
andCONTROL_TO_REMOVE_LAST_POINT
: Controls configurations.ENABLE_UNAUTHORIZE_WARNING_LOGS
: if true, will print a warning when someone is trying to call iZone events without being authorized.
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:isPlayerInAtLeastInOneZoneInCat", "mySuperCat", 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 into the zone (call every tick or every 100 ms, your call):
TriggerEvent("izone:trapPlayerInZone", "zone1")
⚠️ If you came from v1.3 (or less) and you want to use v1.4: Please rename themaxLength
db property tomax_length
. Else it'll NOT works.
- v1.4:
- Removed
__resource.lua
in favor offxmanifest.lua
. - Updated Svelte to the latest version (3.12.1) .
- Fixed an overflow bug #6.
- Some UI improvments.
- Some code cleanup.
- Removed