-
Notifications
You must be signed in to change notification settings - Fork 3
/
Copy pathserver.lua
99 lines (93 loc) · 2.59 KB
/
server.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
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
local ESX = nil
local zones = {}
TriggerEvent('esx:getSharedObject', function(obj) ESX = obj end)
RegisterCommand('setzone', function(source, args, rawCommand)
local xPlayer = ESX.GetPlayerFromId(source)
local identifiers = GetPlayerIdentifiers(source)
if isAuthed(xPlayer) then
local zone = false
for _, v in pairs(identifiers) do
if string.find(v, "license") then
for i, j in pairs(zones) do
if j.id == v then
zone = true
break
end
end
break
end
end
if zone then
TriggerClientEvent("chatMessage", source, "^*^1You already have an active zone! Clear it before trying to create another!.")
else
TriggerClientEvent('adminzone:getCoords', source, 'setzone',Config.pass)
end
else
TriggerClientEvent("chatMessage", source, "^*^1Insufficient Permissions.")
end
end)
RegisterCommand('clearzone', function(source, args, rawCommand)
local xPlayer = ESX.GetPlayerFromId(source)
if isAuthed(xPlayer) then
local identifiers = GetPlayerIdentifiers(source)
local lic = nil
for _, v in pairs(identifiers) do
if string.find(v, "license") then
for i, j in pairs(zones) do
if j.id == v then
table.remove(zones, i)
break
end
end
break
end
end
TriggerClientEvent("adminzone:UpdateZones", -1, zones , Config.pass)
else
TriggerClientEvent("chatMessage", source, "^*^1Insufficient Permissions.")
end
end)
AddEventHandler('playerDropped', function (reason)
local identifiers = GetPlayerIdentifiers(source)
for _, v in pairs(identifiers) do
if string.find(v, "license") then
for i, j in pairs(zones) do
if j.id == v then
table.remove(zones, i)
break
end
end
break
end
end
end)
RegisterNetEvent('adminzone:sendCoords')
AddEventHandler('adminzone:sendCoords', function(command, coords)
local xPlayer = ESX.GetPlayerFromId(source)
if isAuthed(xPlayer) then
if command == 'setzone' then
local identifiers = GetPlayerIdentifiers(source)
for _, v in pairs(identifiers) do
if string.find(v, "license") then
print(v)
table.insert(zones, {id = v, coord = coords})
TriggerClientEvent("chatMessage", source, "^*Added Zone!")
TriggerClientEvent("adminzone:UpdateZones", -1, zones , Config.pass)
break
end
end
end
end
end)
RegisterNetEvent('adminzone:ServerUpdateZone')
AddEventHandler('adminzone:ServerUpdateZone', function()
TriggerClientEvent('adminzone:UpdateZones', source, zones, Config.pass)
end)
function isAuthed(xPlayer)
for k, v in ipairs(Config.groups) do
if xPlayer.getGroup() == v then
return true
end
end
return false
end