This commit is contained in:
Nordi98 2025-08-04 04:28:47 +02:00
parent 875c8448e1
commit c81ae4bb6d
219 changed files with 8036 additions and 7 deletions

View file

@ -0,0 +1,177 @@
local target = exports.ox_target
local Target = {}
-- for options is exactly the same as https://overextended.dev/ox_target
-- Example
-- add up here
local funcs = {
{
name = "addBoxZone",
originalname = "addBoxZone",
args = function(data)
for _, value in ipairs(data.options) do
value.distance = value.distance or data.distance
end -- a simple adjust
return {
coords = data.coords,
size = data.size,
rotation = data.rotation,
debug = data.debug,
drawSprite = data.drawSprite,
options = data.options
}
end
},
{
name = "addLocalEntity",
originalname = "addLocalEntity",
args = function(data)
for _, value in ipairs(data.options) do
value.distance = value.distance or data.distance
end -- a simple adjust
return table.unpack({data.entity, data.options})
end
},
{
name = "addModel",
originalname = "addModel",
args = function(data)
return table.unpack({data.models, data.options})
end
},
{
name = "addCircleZone",
originalname = "addSphereZone",
args = function(data)
for _, value in ipairs(data.options) do
value.distance = value.distance or data.distance
end -- a simple adjust
return {
coords = data.coords,
radius = data.radius,
rotation = data.rotation,
debug = data.debug,
drawSprite = data.drawSprite,
options = data.options
}
end
},
{
name = "addEntity",
originalname = "addEntity",
args = function(data)
local options, distance, entity in data
for _, value in ipairs(options) do
value.distance = value.distance or distance
end -- a simple adjust
local entities = {}
for k,v in ipairs(type(entity) == 'table' and entity or {entity}) do
entities[k] = DoesEntityExist(v) and NetworkGetEntityIsNetworked(v) and NetworkGetNetworkIdFromEntity(v)
end
return table.unpack({entities, options})
end
},
{
name = "removeZone",
originalname = "removeZone",
args = function(data)
return data
end
},
{
name = "removeModel",
originalname = "removeModel",
args = function(data)
return table.unpack({data.models, data.names})
end
},
{
name = "removeLocalEntity",
originalname = "removeLocalEntity",
args = function(data)
return table.unpack({data.entity, data.names})
end
},
{
name = "removeEntity",
originalname = "removeEntity",
args = function(data)
local names, entity in data
local entities = {}
for k,v in ipairs(type(entity) == 'table' and entity or {entity}) do
entities[k] = DoesEntityExist(v) and NetworkGetEntityIsNetworked(v) and NetworkGetNetworkIdFromEntity(v)
end
return table.unpack({entities, names})
end
},
}
for _, exportData in ipairs(funcs) do
Target[exportData.name] = function(data)
local originalName = exportData.originalname or exportData.name
return target[originalName]("bruh", exportData.args(data)) -- already return id
end
end
-- for options is exactly the same as https://overextended.dev/ox_target
-- Example
--[[ local id = Target.addBoxZone({
coords = vector3(428, -973.44, 30.71),
size = vector3(2, 2, 2),
rotation = 90,
distance = 5.0,
debug = true,
options = {
{
label = "W",
icon = "fa-solid fa-scissors",
onSelect = function()
print("frist")
end
},
{
label = "Destroy",
icon = "fa-regular fa-eye",
onSelect = function()
print("second")
end
}
}
}
)
print(id)
Target.removeZone(id)
Target.addCircleZone({
coords = vector3(428, -973.44, 30.71),
radius = 2,
rotation = 90,
distance = 5.0,
debug = true,
options = {
{
label = "W",
icon = "fa-solid fa-scissors",
onSelect = function()
print("frist")
end
},
{
label = "Destroy",
icon = "fa-regular fa-eye",
onSelect = function()
print("second")
end
}
}
}
)
]]
return Target

View file

@ -0,0 +1,204 @@
local targetName = 'qb-target'
-- Check resource state
if GetResourceState(targetName) ~= 'started' then
error(targetName .. ' isn\'t started')
return
end
local target = exports[targetName]
local Utils = require'utils'
local retreiveNumberIndexedData = Utils.retreiveNumberIndexedData
local Target = {}
local OverrideData = {
label = { originalMethod = 'label' },
type = {
originalMethod = { 'event', 'serverEvent' },
modifier = {
executeFunc = true,
effect = function(value, originalMethod)
return originalMethod == 'event' and 'client' or originalMethod == 'serverEvent' and 'server'
end
}
},
event = {
originalMethod = { 'event', 'serverEvent' }
},
icon = {
originalMethod = 'icon',
},
targeticon = {
originalMethod = 'targeticon',
},
item = {
originalMethod = 'items'
},
action = {
originalMethod = 'onSelect',
},
canInteract = {
originalMethod = 'canInteract',
},
job = {
originalMethod = 'groups',
},
gang = {
originalMethod = 'groups',
}
}
-- alot of them have exclusive args
-- add up here
local funcs = {
{
name = "addBoxZone",
originalname = "AddBoxZone",
args = function(data, id)
local length, width = table.unpack(data.size)
return { id, data.coords, length, width, {
name = id,
heading = data.rotation,
debugPoly = data.debug,
} }
end
},
{
name = "addCircleZone",
originalname = "AddCircleZone",
args = function(data, id)
return { id, data.coords, data.radius, {
name = id,
heading = data.rotation,
debugPoly = data.debug,
} }
end
},
{
name = "addModel",
originalname = "AddTargetModel",
args = function(data)
return {data.models}
end
},
{
name = "addEntity",
originalname = "AddTargetEntity",
args = function(data)
return {data.entity}
end
},
{
name = "addLocalEntity",
originalname = "AddTargetEntity",
args = function(data)
return {data.entity}
end
},
{
name = "removeZone",
originalname = "RemoveZone",
args = function(data)
return data
end
},
{
name = "removeEntity",
originalname = "RemoveTargetEntity",
args = function(data)
return data
end
},
{
name = "removeLocalEntity",
originalname = "RemoveTargetEntity",
args = function(data)
return data
end
},
}
-- dynamic way of creating funcs for the target, i will make it global in the future
for _, exportData in ipairs(funcs) do
Target[exportData.name] = function(data)
local id = Utils.await('UUID', false, 8)
local originalName = exportData.originalname or exportData.name
local args = exportData.args(data, id)
if type(data) == "table" and type(data.options) == "table" then
if not data.options[1] then
data.options = { data.options }
end
args[#args + 1] = {
options = retreiveNumberIndexedData(data.options, OverrideData),
distance = data.distance
}
end
if type(args) == "table" then
target[originalName]("bruh", table.unpack(args))
else
target[originalName]("bruh", args)
end
return id
end
end
-- for options is exactly the same as https://overextended.dev/ox_target
-- Example
--[[ local id = Target.addBoxZone({
coords = vector3(428, -973.44, 30.71),
size = vector3(2, 2, 2),
rotation = 90,
distance = 5.0,
debug = true,
options = {
{
label = "W",
icon = "fa-solid fa-scissors",
onSelect = function()
print("frist")
end
},
{
label = "Destroy",
icon = "fa-regular fa-eye",
onSelect = function()
print("second")
end
}
}
}
)
local id2 = Target.addCircleZone({
coords = vector3(428, -973.44, 30.71),
radius = 2,
rotation = 90,
distance = 5.0,
debug = true,
options = {
{
label = "W",
icon = "fa-solid fa-scissors",
serverEvent = 'dwadaw',
},
{
label = "Destroy",
icon = "fa-regular fa-eye",
onSelect = function()
print("second")
end
}
}
}
)
]]
return Target