forked from Big-Yoda/Star-Chase
-
Notifications
You must be signed in to change notification settings - Fork 4
/
Copy pathcl_tracker.lua
63 lines (58 loc) · 2.09 KB
/
cl_tracker.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
local trackedveh = nil
local deployed = false
Citizen.CreateThread(function()
while true do
Citizen.Wait(0)
if ( IsControlJustPressed(0,244) and IsPedInAnyVehicle(GetPlayerPed(-1)) and IsPedInAnyPoliceVehicle(GetPlayerPed(-1)) ) then
if ( deployed == true ) then
deployed = false
TriggerEvent("tracker:trackerremove")
elseif ( deployed == false ) then
deployed = true
TriggerEvent("tracker:trackerset")
end
end
end
end)
RegisterNetEvent("tracker:trackerremove")
AddEventHandler("tracker:trackerremove", function()
if deployed then
deployed = false
local plycoords = GetEntityCoords(GetPlayerPed(-1))
SetNewWaypoint(plycoords.x + 2, plycoords.y)
showNotification("~h~~o~Biljakt~h~: ~w~Biljakt avslutad!")
end
end)
RegisterNetEvent("tracker:trackerset")
AddEventHandler("tracker:trackerset", function()
trackedveh = GetTrackedVeh(GetVehiclePedIsIn(GetPlayerPed(-1)))
deployed = true
while deployed do
Citizen.Wait(0)
if trackedveh ~= nil then
if IsEntityAVehicle(trackedveh) then
local coords = GetEntityCoords(trackedveh)
showNotification("~o~~h~Biljakt:~h~~w~ Biljakt inledd!!\n~h~Bilmodell:~h~ "..GetLabelText(GetDisplayNameFromVehicleModel(GetEntityModel(trackedveh))).."\n~h~Registeringsnummer:~h~ "..GetVehicleNumberPlateText(trackedveh))
SetNewWaypoint(coords.x, coords.y)
end
else
deployed = false
end
end
end)
function GetTrackedVeh(e)
local coord1 = GetOffsetFromEntityInWorldCoords(e, 0.0, 1.0, 1.0)
local coord2 = GetOffsetFromEntityInWorldCoords(e, 0.0, 25.0, 0.0)
local rayresult = StartShapeTestCapsule(coord1, coord2, 3.0, 10, e, 7)
local a, b, c, d, e = GetShapeTestResult(rayresult)
if DoesEntityExist(e) then
return e
else
return nil
end
end
function showNotification(string)
SetNotificationTextEntry("STRING")
AddTextComponentString(string)
DrawNotification(false, false)
end