forked from qbcore-framework/qb-policejob
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathanpr.lua
56 lines (50 loc) · 1.65 KB
/
anpr.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
local lastRadar = nil
local HasAlreadyEnteredMarker = false
local function IsInMarker(playerPos, speedCam)
return #(playerPos - vector3(speedCam.x, speedCam.y, speedCam.z)) < 20.0
end
local function HandleSpeedCam(speedCam, radarID)
local playerPed = PlayerPedId()
local playerPos = GetEntityCoords(playerPed)
local isInMarker = IsInMarker(playerPos, speedCam)
if isInMarker and not HasAlreadyEnteredMarker and lastRadar == nil then
HasAlreadyEnteredMarker = true
lastRadar = radarID
local vehicle = GetPlayersLastVehicle()
if IsPedInAnyVehicle(playerPed, false) and GetPedInVehicleSeat(vehicle, -1) == playerPed and GetVehicleClass(vehicle) ~= 18 then
local plate = QBCore.Functions.GetPlate(vehicle)
QBCore.Functions.TriggerCallback('police:IsPlateFlagged', function(isFlagged)
if isFlagged then
local coords = GetEntityCoords(playerPed)
local blipsettings = {
x = coords.x,
y = coords.y,
z = coords.z,
sprite = 488,
color = 1,
scale = 0.9,
text = 'Speed camera #' .. radarID .. ' - Marked vehicle'
}
local street1, street2 = table.unpack(GetStreetNameAtCoord(coords.x, coords.y, coords.z))
TriggerServerEvent('police:server:FlaggedPlateTriggered', radarID, plate, street1, street2, blipsettings)
end
end, plate)
end
end
if not isInMarker and HasAlreadyEnteredMarker and lastRadar == radarID then
HasAlreadyEnteredMarker = false
lastRadar = nil
end
end
CreateThread(function()
while true do
if IsPedInAnyVehicle(PlayerPedId(), false) then
for key, value in pairs(Config.Radars) do
HandleSpeedCam(value, key)
end
Wait(200)
else
Wait(2500)
end
end
end)