-
Notifications
You must be signed in to change notification settings - Fork 17
/
Main.lua
84 lines (71 loc) · 2.42 KB
/
Main.lua
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
local Zones = {}
local Active = {}
local Combo = nil
local function UpdateComboZone(zone)
if Combo == nil then
Combo = ComboZone:Create({zone}, {name="combo", debugPoly=false})
Active[zone["name"]] = zone
Combo:onPlayerInOutExhaustive(function(isPointInside, point, insideZones, enteredZones, leftZones)
if enteredZones then
for i=1, #enteredZones do
--print("Entered: " ..enteredZones[i]["name"])
TriggerEvent("ps-zones:enter", enteredZones[i]["name"], enteredZones[i]["data"])
TriggerServerEvent("ps-zones:enter", enteredZones[i]["name"], enteredZones[i]["data"])
end
end
if leftZones then
for i=1, #leftZones do
--print("Left: " ..leftZones[i]["name"])
TriggerEvent("ps-zones:leave", leftZones[i]["name"], leftZones[i]["data"])
TriggerServerEvent("ps-zones:leave", leftZones[i]["name"], leftZones[i]["data"])
end
end
end)
else
Combo:AddZone(zone)
Active[zone["name"]] = zone
end
end
local function ZoneExist(name)
if Active[name] then
return true
else
return false
end
end
exports("CreateBoxZone", function(name, point, length, width, data)
if ZoneExist(name) then return print("Zone with that name already exists") end
if not data then data = {} end
data.name = name
local box = BoxZone:Create(point, length, width, data)
UpdateComboZone(box)
end)
exports("CreatePolyZone", function(name, points, data)
if ZoneExist(name) then return print("Zone with that name already exists") end
if not data then data = {} end
data.name = name
local poly = PolyZone:Create(points, data)
UpdateComboZone(poly)
end)
exports("CreateCircleZone", function(name, point, radius, data)
if ZoneExist(name) then return print("Zone with that name already exists") end
if not data then data = {} end
data.name = name
local circle = CircleZone:Create(point, radius, data)
UpdateComboZone(circle)
end)
exports("CreateEntityZone", function(name, entity, data)
if ZoneExist(name) then return print("Zone with that name already exists") end
if not data then data = {} end
data.name = name
local entity = EntityZone:Create(entity, data)
UpdateComboZone(entity)
end)
exports("DestroyZone", function(name)
if not ZoneExist(name) then return print("Zone doesn't exist") end
if Active[name] then
Combo:RemoveZone(name)
Active[name]:destroy()
Active[name] = nil
end
end)