forked from nick-perry14/esx_adminzone
-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathserver.lua
More file actions
67 lines (59 loc) · 2.06 KB
/
server.lua
File metadata and controls
67 lines (59 loc) · 2.06 KB
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
local QBCore = exports['qb-core']:GetCoreObject()
local zones = {}
QBCore.Commands.Add("setzone", "Set Report Zone (Admin Only)", {}, false, function(source)
local src = source
local Player = QBCore.Functions.GetPlayer(src)
local license = Player.PlayerData.license
local zone = false
for i, j in pairs(zones) do
if j.id == license then
zone = true
break
end
end
if zone then
TriggerClientEvent("chatMessage", src, "^*^1You already have an active zone! Clear it before trying to create another!.")
else
TriggerClientEvent("adminzone:getCoords", src, "setzone", Config.pass)
end
end, "admin")
QBCore.Commands.Add("clearzone", "Set Report Zone (Admin Only)", {}, false, function(source)
local src = source
local Player = QBCore.Functions.GetPlayer(src)
local license = Player.PlayerData.license
for i, j in pairs(zones) do
if j.id == license then
table.remove(zones, i)
break
end
end
TriggerClientEvent("adminzone:UpdateZones", -1, zones , Config.pass)
end, "admin")
AddEventHandler('playerDropped', function (reason)
local src = source
if QBCore.Players[src] then
local license = Player.PlayerData.license
for i, j in pairs(zones) do
if j.id == license then
table.remove(zones, i)
break
end
end
end
end)
RegisterNetEvent('adminzone:sendCoords')
AddEventHandler('adminzone:sendCoords', function(command, coords)
local src = source
local Player = QBCore.Functions.GetPlayer(src)
if QBCore.Functions.HasPermission(src, 'admin') or QBCore.Functions.HasPermission(src, 'god') then
if command == 'setzone' then
table.insert(zones, {id = Player.PlayerData.license, coord = coords})
TriggerClientEvent("chatMessage", source, "^*Added Zone!")
TriggerClientEvent("adminzone:UpdateZones", -1, zones , Config.pass)
end
end
end)
RegisterNetEvent('adminzone:ServerUpdateZone')
AddEventHandler('adminzone:ServerUpdateZone', function()
TriggerClientEvent('adminzone:UpdateZones', source, zones, Config.pass)
end)