-
Notifications
You must be signed in to change notification settings - Fork 4
/
Copy pathserver.lua
65 lines (42 loc) · 1.68 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
QBCore = exports['qb-core']:GetCoreObject()
local time_out = {}
RegisterServerEvent("qb-pdvehtracker", function(plate)
local xPlayers = QBCore.Functions.GetPlayers()
for i=1, #xPlayers, 1 do
local xPlayer = QBCore.Functions.GetPlayer(xPlayers[i])
if xPlayer.PlayerData.job.name == 'police' then
TriggerClientEvent("qb-pdvehtracker:plate", xPlayers[i], plate)
end
end
end)
RegisterServerEvent("qb-pdvehtracker:setActivePlates", function(plate)
time_out[plate] = false
end)
RegisterServerEvent("qb-pdvehtracker:removeActivePlate", function(plate)
time_out[plate] = time_out[nil]
local xPlayers = QBCore.Functions.GetPlayers()
for i=1, #xPlayers, 1 do
local xPlayer = QBCore.Functions.GetPlayer(xPlayers[i])
if xPlayer.PlayerData.job.name == 'police' then
TriggerClientEvent("qb-pdvehtracker:updateActivePlate", xPlayers[i], plate)
end
end
end)
RegisterServerEvent("qb-pdvehtracker:getActivePlates", function()
TriggerClientEvent("qb-pdvehtracker:getActivePlates", source, time_out)
end)
RegisterServerEvent("qb-pdvehtracker:triggerTimer", function(plate)
local xPlayers = QBCore.Functions.GetPlayers()
local startTimer = os.time() + Config.removeTimer
CreateThread(function()
while os.time() < startTimer and time_out[plate] ~= nil do
Wait(5)
end
for i=1, #xPlayers, 1 do
local xPlayer = QBCore.Functions.GetPlayer(xPlayers[i])
if xPlayer.PlayerData.job.name == 'police' then
TriggerClientEvent("qb-pdvehtracker:updateTimer", xPlayers[i], plate)
end
end
end)
end)