forked from qbcore-framework/qb-target
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathinit.lua
More file actions
185 lines (139 loc) · 4.49 KB
/
Copy pathinit.lua
File metadata and controls
185 lines (139 loc) · 4.49 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
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
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
function Load(name)
local resourceName = GetCurrentResourceName()
local chunk = LoadResourceFile(resourceName, ('data/%s.lua'):format(name))
if chunk then
local err
chunk, err = load(chunk, ('@@%s/data/%s.lua'):format(resourceName, name), 't')
if err then
error(('\n^1 %s'):format(err), 0)
end
return chunk()
end
end
-------------------------------------------------------------------------------
-- Settings
-------------------------------------------------------------------------------
Config = {}
-- It's possible to interact with entities through walls so this should be low
Config.MaxDistance = 5.0
-- Enable debug options
Config.Debug = false
-- Supported values: true, false
Config.Standalone = false
-- Enable outlines around the entity you're looking at
Config.EnableOutline = false
-- Enable default options (Toggling vehicle doors)
Config.EnableDefaultOptions = true
-- Disable the target eye whilst being in a vehicle
Config.DisableInVehicle = false
-- Key to open the target
Config.OpenKey = 'LMENU' -- Left Alt
Config.OpenControlKey = 19 -- Control for keypress detection also Left Alt for the eye itself, controls are found here https://docs.fivem.net/docs/game-references/controls/
-- Key to open the menu
Config.MenuControlKey = 238 -- Control for keypress detection on the context menu, this is the Right Mouse Button, controls are found here https://docs.fivem.net/docs/game-references/controls/
-------------------------------------------------------------------------------
-- Target Configs
-------------------------------------------------------------------------------
-- These are all empty for you to fill in, refer to the .md files for help in filling these in
Config.CircleZones = {
}
Config.BoxZones = {
}
Config.PolyZones = {
}
Config.TargetBones = {
}
Config.TargetEntities = {
}
Config.TargetModels = {
}
Config.GlobalPedOptions = {
}
Config.GlobalVehicleOptions = {
}
Config.GlobalObjectOptions = {
}
Config.GlobalPlayerOptions = {
}
Config.Peds = {
}
-------------------------------------------------------------------------------
-- Functions
-------------------------------------------------------------------------------
local function JobCheck() return true end
local function GangCheck() return true end
local function ItemCount() return true end
local function CitizenCheck() return true end
CreateThread(function()
if not Config.Standalone then
local QBCore = exports['qb-core']:GetCoreObject()
local PlayerData = QBCore.Functions.GetPlayerData()
ItemCount = function(item)
for _, v in pairs(PlayerData.items) do
if v.name == item then
return true
end
end
return false
end
JobCheck = function(job)
if type(job) == 'table' then
job = job[PlayerData.job.name]
if job and PlayerData.job.grade.level >= job then
return true
end
elseif job == 'all' or job == PlayerData.job.name then
return true
end
return false
end
GangCheck = function(gang)
if type(gang) == 'table' then
gang = gang[PlayerData.gang.name]
if gang and PlayerData.gang.grade.level >= gang then
return true
end
elseif gang == 'all' or gang == PlayerData.gang.name then
return true
end
return false
end
CitizenCheck = function(citizenid)
return citizenid == PlayerData.citizenid or citizenid[PlayerData.citizenid]
end
RegisterNetEvent('QBCore:Client:OnPlayerLoaded', function()
PlayerData = QBCore.Functions.GetPlayerData()
SpawnPeds()
end)
RegisterNetEvent('QBCore:Client:OnPlayerUnload', function()
PlayerData = {}
DeletePeds()
end)
RegisterNetEvent('QBCore:Client:OnJobUpdate', function(JobInfo)
PlayerData.job = JobInfo
end)
RegisterNetEvent('QBCore:Client:OnGangUpdate', function(GangInfo)
PlayerData.gang = GangInfo
end)
RegisterNetEvent('QBCore:Player:SetPlayerData', function(val)
PlayerData = val
end)
else
local firstSpawn = false
AddEventHandler('playerSpawned', function()
if not firstSpawn then
SpawnPeds()
firstSpawn = true
end
end)
end
end)
function CheckOptions(data, entity, distance)
if distance and data.distance and distance > data.distance then return false end
if data.job and not JobCheck(data.job) then return false end
if data.gang and not GangCheck(data.gang) then return false end
if data.item and not ItemCount(data.item) then return false end
if data.citizenid and not CitizenCheck(data.citizenid) then return false end
if data.canInteract and not data.canInteract(entity, distance, data) then return false end
return true
end