/
cl_tracking.lua
142 lines (130 loc) · 5.36 KB
/
cl_tracking.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
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
local entitiesToDraw = {}
local itemsToDraw = {}
local vehiclesToDraw = {}
local trackPeds = true
local trackVehicles = true
local trackEntities = true
Citizen.CreateThread(function()
-- Surrounding Info / Tracking
while Config.EnableTracking do
Citizen.Wait(1)
if IsControlJustReleased(2, 0x446258B6) then -- PageUp
trackPeds = not trackPeds
trackVehicles = not trackVehicles
end
if IsControlJustReleased(2, 0x3C3DD371) then -- PageDown
trackEntities = not trackEntities
end
if trackEntities then
local player = PlayerPedId()
local coords = GetEntityCoords(player)
-- World - Ground / Walls / Rocks
-- Below Player
local shapeTest = StartShapeTestRay(coords.x, coords.y, coords.z, coords.x, coords.y, coords.z - 5.0, 1, 1)
local rtnVal, hit, endCoords, surfaceNormal, entityHit = GetShapeTestResult(shapeTest)
if hit > 0 then
TxtAtWorldCoord(endCoords.x, endCoords.y, endCoords.z, "Standing On: " .. tostring(entityHit), 0.15, 9)
end
-- World - Ground / Walls / Rocks
-- Infront of Player
local coordsf = GetOffsetFromEntityInWorldCoords(player, 0.0, 2.5, 0.0)
local shapeTest = StartShapeTestRay(coords.x, coords.y, coords.z, coordsf.x, coordsf.y, coordsf.z, 1)
local rtnVal, hit, endCoords, surfaceNormal, entityHit = GetShapeTestResult(shapeTest)
if hit > 0 then
TxtAtWorldCoord(endCoords.x, endCoords.y, endCoords.z, "1: " .. tostring(entityHit), 0.3, 9)
end
end
DrawTrackedInfo()
end
end)
-- local volumeArea = CreateVolumeBox(0.0, 0.0, 0.0, 0.0, 0.0, 0.0, DrawDistance * 2, DrawDistance * 2, DrawDistance * 2)
-- local volumeArea = CreateVolumeCylinder(0.0, 0.0, 0.0, 0.0, 0.0, 0.0, DrawDistance, DrawDistance, DrawDistance)
local volumeArea = Citizen.InvokeNative(0xB3FB80A32BAE3065, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, DrawDistance, DrawDistance, DrawDistance) -- _CREATE_VOLUME_SPHERE
-- Citizen.InvokeNative(0x43F867EF5C463A53, volumeArea) -- _DELETE_VOLUME
local itemSet = CreateItemset(1)
Citizen.CreateThread(function()
-- Surrounding Info / Tracking
while Config.EnableTracking do
Wait(500)
local player = PlayerPedId()
entitiesToDraw = {}
itemsToDraw = {}
foliageToDraw = {}
vehiclesToDraw = {}
local coords = GetEntityCoords(player)
if volumeArea then
-- 0x541B8576615C33DE SET_VOLUME_COORDS
-- 0xA07CF1B21B56F041 SET_VOLUME_ROTATION
-- 0xA46E98BDC407E23D SET_VOLUME_SIZE
Citizen.InvokeNative(0x541B8576615C33DE, volumeArea, coords.x, coords.y, coords.z) -- SET_VOLUME_COORDS
-- 1 Peds
-- 2 Vehicles
-- 3 Entities
if trackPeds then
local itemsFound = Citizen.InvokeNative(0x886171A12F400B89, volumeArea, itemSet, 1) -- Get volume items into itemset
if itemsFound then
n = 0
while n < itemsFound do
entitiesToDraw[(GetIndexedItemInItemset(n, itemSet))] = true
n = n + 1
end
end
Citizen.InvokeNative(0x20A4BF0E09BEE146, itemSet) -- Empty Item Set
end
if trackVehicles then
local itemsFound = Citizen.InvokeNative(0x886171A12F400B89, volumeArea, itemSet, 2) -- Get volume items into itemset
if itemsFound then
n = 0
while n < itemsFound do
vehiclesToDraw[(GetIndexedItemInItemset(n, itemSet))] = true
n = n + 1
end
end
Citizen.InvokeNative(0x20A4BF0E09BEE146, itemSet) -- Empty Item Set
end
if trackEntities then
local itemsFound = Citizen.InvokeNative(0x886171A12F400B89, volumeArea, itemSet, 3) -- Get volume items into itemset
if itemsFound then
n = 0
while n < itemsFound do
itemsToDraw[(GetIndexedItemInItemset(n, itemSet))] = true
n = n + 1
end
end
Citizen.InvokeNative(0x20A4BF0E09BEE146, itemSet) -- Empty Item Set
end
end
end
end)
function DrawTrackedInfo()
if trackPeds then
for entity, active in pairs(entitiesToDraw) do
if not DoesEntityExist(entity) then
active = false
end
if active and IsEntityOnScreen(entity) then
DrawEntityInfo(entity)
end
end
end
if trackEntities then
for entity, active in pairs(itemsToDraw) do
if not DoesEntityExist(entity) then
active = false
end
if active and IsEntityOnScreen(entity) then
DrawItemInfo(entity)
end
end
end
if trackVehicles then
for entity, active in pairs(vehiclesToDraw) do
if not DoesEntityExist(entity) then
active = false
end
if active and IsEntityOnScreen(entity) then
DrawVehicleInfo(entity)
end
end
end
end