This commit is contained in:
Nordi98 2025-08-06 16:37:06 +02:00
parent 510e3ffcf2
commit f43cf424cf
305 changed files with 34683 additions and 0 deletions

View file

@ -0,0 +1,141 @@
---@diagnostic disable: duplicate-set-field
Target = Target or {}
local function warnUser()
print("Currently Only Targeting Is Supported By Community Bridge, You Are Using A Resource That Requires The Target Module To Be Used.")
end
Target.FixOptions = function(options)
for k, v in pairs(options) do
local action = v.onSelect or v.action
local select = function(entityOrData)
if type(entityOrData) == 'table' then
return action(entityOrData.entity)
end
return action(entityOrData)
end
options[k].onSelect = select
end
return options
end
Target.AddGlobalPlayer = function(options)
warnUser()
end
Target.AddGlobalVehicle = function(options)
warnUser()
end
Target.RemoveGlobalVehicle = function(options)
warnUser()
end
Target.AddLocalEntity = function(entities, _options)
local fixedOptions = Target.FixOptions(_options)
if type(entities) == "string" or type(entities) == "number" then
entities = { entities }
end
for _, entity in pairs(entities) do
local id = Ids.RandomString()
local menuData = { id = id, title = "Options", options = {} }
for k, v in pairs(fixedOptions) do
table.insert(menuData.options, {
title = ("Option " .. k),
description = "No Description",
icon = v.icon or "fas fa-code-pull-request",
args = {},
onSelect = function(selected, secondary, args)
if v.onSelect then
v.onSelect(selected, secondary, args)
end
end
})
end
Point.Register(id, entity, 5, args,
function()
local coords = GetEntityCoords(entity)
local sleep = 3000
while DoesEntityExist(entity) do
Wait(sleep)
local distance = #(coords - GetEntityCoords(PlayerPedId()))
if distance < 10 then
sleep = 0
Utility.Draw3DHelpText(coords, "Press [E] To Interact", 0.35)
if IsControlJustPressed(0, 38) then
Menu.Open(menuData, false)
end
else
sleep = 3000
end
end
end,
function()
Point.Remove(id)
end, function()
--No need for this in this one
end)
end
end
Target.AddModel = function(models, options)
warnUser()
end
Target.AddBoxZone = function(name, coords, size, heading, options)
local fixedOptions = Target.FixOptions(_options)
local id = Ids.RandomString()
local menuData = { id = id, title = "Options", options = {} }
for k, v in pairs(fixedOptions) do
table.insert(menuData.options, {
title = ("Option " .. k),
description = "No Description",
onSelect = function(selected, secondary, args)
if v.onSelect then
v.onSelect(selected, secondary, args)
end
end
})
end
Point.Register(id, coords, 5, args,
function()
local sleep = 3000
while true do
Wait(sleep)
local distance = #(coords - GetEntityCoords(PlayerPedId()))
if distance < 10 then
sleep = 0
Utility.Draw3DHelpText(coords, "Press [E] To Interact", 0.35)
if IsControlJustPressed(0, 38) then
Menu.Open(menuData, false)
end
else
sleep = 3000
end
end
end,
function()
Point.Remove(id)
end, function()
--No need for this in this one
end)
end
Target.RemoveGlobalPlayer = function()
warnUser()
end
Target.RemoveLocalEntity = function(entity)
warnUser()
end
Target.RemoveModel = function(model)
warnUser()
end
Target.RemoveZone = function(name)
warnUser()
end
return Target

View file

@ -0,0 +1,17 @@
-- local Target = Require('modules/target/_default/init.lua')
local requiredModules = {
'modules/target/_default/client.lua',
'modules/target/qb-target/client.lua',
'modules/target/sleepless_interact/client.lua',
'modules/target/ox_target/client.lua'
}
local Module = nil
for _, path in pairs(requiredModules) do
local module = Require(path)
if module then
Module = module
end
end
return Module or error('No target module found. Please ensure you have one of the required target modules installed: ' .. table.concat(requiredModules, ', '))

View file

@ -0,0 +1,190 @@
---@diagnostic disable: duplicate-set-field
local resourceName = "ox_target"
if GetResourceState(resourceName) == 'missing' then return end
local targetDebug = false
local function detectDebugEnabled()
if BridgeSharedConfig.DebugLevel == 2 then
targetDebug = true
end
end
detectDebugEnabled()
local ox_target = exports.ox_target
local targetZones = {}
Target = Target or {}
---This is an internal function that is used to fix the options passed to fit alternative target systems, for example qb-ox or ox-qb etc.
---@param options table
---@return table
Target.FixOptions = function(options)
for k, v in pairs(options) do
local action = v.onSelect or v.action
local select = function(entityOrData)
if type(entityOrData) == 'table' then
return action(entityOrData.entity)
end
return action(entityOrData)
end
options[k].onSelect = select
options[k].groups = v.job or v.groups
end
return options
end
---This will toggle the targeting system on or off. This is useful for when you want to disable the targeting system for a specific player entirely.
---@param bool boolean
Target.DisableTargeting = function(bool)
ox_target:disableTargeting(bool)
end
---This will add target options to players.
---@param options table
Target.AddGlobalPlayer = function(options)
options = Target.FixOptions(options)
ox_target:addGlobalPlayer(options)
end
---This will remove target options from all players.
Target.RemoveGlobalPlayer = function()
ox_target:removeGlobalPlayer()
end
---This will add target options to all specified models. This is useful for when you want to add target options to all models of a specific type.
---@param options table
Target.AddGlobalPed = function(options)
options = Target.FixOptions(options)
ox_target:addGlobalPed(options)
end
---This will remove target options from all peds. This is useful for when you want to remove target options from all peds.
---@param options any
Target.RemoveGlobalPed = function(options)
ox_target:removeGlobalPed(options)
end
---This will add taget options to all vehicles.
---@param options table
Target.AddGlobalVehicle = function(options)
options = Target.FixOptions(options)
ox_target:addGlobalVehicle(options)
end
---This will remove target options from all vehicles.
---@param options table
Target.RemoveGlobalVehicle = function(options)
local assembledLables = {}
for k, v in pairs(options) do
table.insert(assembledLables, v.name)
end
ox_target:removeGlobalVehicle(assembledLables)
end
---This will generate targets on non networked entites with the passed options.
---@param entities number | table
---@param options table
Target.AddLocalEntity = function(entities, options)
options = Target.FixOptions(options)
ox_target:addLocalEntity(entities, options)
end
---This will remove the target options from a local entity. This is useful for when you want to remove target options from a specific entity.
---@param entities table
---@param optionNames string | table | nil
Target.RemoveLocalEntity = function(entities, optionNames)
ox_target:removeLocalEntity(entities, optionNames)
end
---This will add a networked entity to the target system.
---@param netids table | number
---@param options table
Target.AddNetworkedEntity = function(netids, options)
options = Target.FixOptions(options)
ox_target:addEntity(netids, options)
end
---This will remove a networked entity from the target system.
---@param netids table | number
---@param optionNames string
Target.RemoveNetworkedEntity = function(netids, optionNames)
ox_target:removeEntity(netids, optionNames)
end
---This will add target options to all specified models. This is useful for when you want to add target options to all models of a specific type.
---@param models number | table
---@param options table
Target.AddModel = function(models, options)
options = Target.FixOptions(options)
ox_target:addModel(models, options)
end
---This will remove target options from all specified models.
---@param model number
Target.RemoveModel = function(model)
ox_target:removeModel(model)
end
---This will add a box zone to the target system. This is useful for when you want to add target options to a specific area.
---@param name string
---@param coords table
---@param size table
---@param heading number
---@param options table
Target.AddBoxZone = function(name, coords, size, heading, options, debug)
options = Target.FixOptions(options or {})
if not next(options) then return end
local target = ox_target:addBoxZone({
coords = coords,
size = size,
rotation = heading,
debug = debug or targetDebug,
options = options,
})
table.insert(targetZones, { name = name, id = target, creator = GetInvokingResource() })
return target
end
---This will add a circle zone to the target system. This is useful for when you want to add target options to a specific area.
---@param name string
---@param coords table
---@param radius number
---@param options table
Target.AddSphereZone = function(name, coords, radius, heading, options)
options = Target.FixOptions(options)
local target = ox_target:addSphereZone({
coords = coords,
radius = radius,
name = name,
debug = targetDebug,
options = options
})
table.insert(targetZones, { name = name, id = target, creator = GetInvokingResource() })
return target
end
---This will remove target options from a specific zone.
---@param name string
Target.RemoveZone = function(name)
if not name then return end
for _, data in pairs(targetZones) do
if data.name == name then
ox_target:removeZone(data.id)
table.remove(targetZones, _)
break
end
end
end
AddEventHandler('onResourceStop', function(resource)
if resource ~= GetCurrentResourceName() then return end
for _, target in pairs(targetZones) do
if target.creator == resource then
ox_target:removeZone(target.id)
end
end
targetZones = {}
end)
return Target

View file

@ -0,0 +1,208 @@
---@diagnostic disable: duplicate-set-field
local resourceName = "qb-target"
if GetResourceState(resourceName) == 'missing' then return end
if GetResourceState("ox_target") == 'started' then return end
local targetDebug = false
local function detectDebugEnabled()
if BridgeSharedConfig.DebugLevel == 2 then
targetDebug = true
end
end
detectDebugEnabled()
local targetZones = {}
Target = Target or {}
local qb_target = exports['qb-target']
---This is an internal function that is used to fix the options passed to fit alternative target systems, for example qb-ox or ox-qb etc.
---@param options table
---@return table
Target.FixOptions = function(options)
for k, v in pairs(options) do
local action = v.onSelect or v.action
local select = function(entityOrData)
if type(entityOrData) == 'table' then
return action(entityOrData.entity)
end
return action(entityOrData)
end
options[k].action = select
options[k].job = v.job or v.groups
end
return options
end
---This will toggle the targeting system on or off. This is useful for when you want to disable the targeting system for a specific player entirely.
---@param bool boolean
Target.DisableTargeting = function(bool)
qb_target:AllowTargeting(not bool)
end
---This will add target options to players.
---@param options table
Target.AddGlobalPlayer = function(options)
options = Target.FixOptions(options)
qb_target:AddGlobalPlayer({
options = options,
distance = options.distance or 1.5
})
end
---This will remove target options from all players.
Target.RemoveGlobalPlayer = function()
qb_target:RemoveGlobalPlayer()
end
---This will add target options to all specified models. This is useful for when you want to add target options to all models of a specific type.
---@param options table
Target.AddGlobalPed = function(options)
options = Target.FixOptions(options)
qb_target:AddGlobalPed({
options = options,
distance = options.distance or 1.5
})
end
---This will remove target options from all peds. This is useful for when you want to remove target options from all peds.
---@param options any
Target.RemoveGlobalPed = function(options)
qb_target:RemoveGlobalPed(options)
end
---This will add taget options to all vehicles.
---@param options table
Target.AddGlobalVehicle = function(options)
options = Target.FixOptions(options)
qb_target:AddGlobalVehicle({
options = options,
distance = options.distance or 1.5
})
end
---This will add a networked entity to the target system.
---@param netids table | number
---@param options table
Target.AddNetworkedEntity = function(netids, options)
options = Target.FixOptions(options)
qb_target:AddTargetEntity(netids, options)
end
---This will remove a networked entity from the target system.
---@param netids table | number
---@param optionNames string
Target.RemoveNetworkedEntity = function(netids, optionNames)
qb_target:RemoveTargetEntity(netids, optionNames)
end
---This will remove target options from all vehicles.
---@param options table
Target.RemoveGlobalVehicle = function(options)
local assembledLables = {}
for k, v in pairs(options) do
table.insert(assembledLables, v.label)
end
qb_target:RemoveGlobalVehicle(assembledLables)
end
---This will generate targets on non networked entites with the passed options.
---@param entities number | table
---@param options table
Target.AddLocalEntity = function(entities, options)
options = Target.FixOptions(options)
qb_target:AddTargetEntity(entities, {
options = options,
distance = options.distance or 1.5
})
end
---This will remove the target options from a local entity. This is useful for when you want to remove target options from a specific entity.
---@param entity number | table
---@param labels string | table | nil
Target.RemoveLocalEntity = function(entity, labels)
qb_target:RemoveTargetEntity(entity, labels)
end
---This will add target options to all specified models. This is useful for when you want to add target options to all models of a specific type.
---@param models number | table
---@param options table
Target.AddModel = function(models, options)
options = Target.FixOptions(options)
qb_target:AddTargetModel(models, {
options = options,
distance = options.distance or 1.5,
})
end
---This will remove target options from all specified models.
---@param model number
Target.RemoveModel = function(model)
qb_target:RemoveTargetModel(model)
end
---This will add a box zone to the target system. This is useful for when you want to add target options to a specific area.
---@param name string
---@param coords table
---@param size table
---@param heading number
---@param options table
Target.AddBoxZone = function(name, coords, size, heading, options, debug)
options = Target.FixOptions(options)
if not next(options) then return end
qb_target:AddBoxZone(name, coords, size.x, size.y, {
name = name,
debugPoly = debug or targetDebug,
heading = heading,
minZ = coords.z - (size.z * 0.5),
maxZ = coords.z + (size.z * 0.5),
}, {
options = options,
distance = options.distance or 1.5,
})
table.insert(targetZones, { name = name, creator = GetInvokingResource() })
end
---This will add a circle zone to the target system. This is useful for when you want to add target options to a specific area.
---@param name string
---@param coords table
---@param radius number
---@param options table
Target.AddSphereZone = function(name, coords, radius, options)
options = Target.FixOptions(options)
qb_target:AddCircleZone(name, coords, radius, {
name = name,
debugPoly = targetDebug,
}, {
options = options,
distance = options.distance or 1.5,
})
table.insert(targetZones, { name = name, creator = GetInvokingResource() })
end
---This will remove target options from a specific zone.
---@param name string
Target.RemoveZone = function(name)
if not name then return end
for _, data in pairs(targetZones) do
if data.name == name then
qb_target:RemoveZone(name)
table.remove(targetZones, _)
break
end
end
end
AddEventHandler('onResourceStop', function(resource)
if resource ~= GetCurrentResourceName() then return end
for _, target in pairs(targetZones) do
if target.creator == resource then
qb_target:RemoveZone(target.name)
end
end
targetZones = {}
end)
return Target

View file

@ -0,0 +1,183 @@
---@diagnostic disable: duplicate-set-field
local resourceName = "sleepless_interact"
if GetResourceState(resourceName) == 'missing' then return end
if GetResourceState("ox_target") == 'started' then return end
local targetDebug = false
local function detectDebugEnabled()
if BridgeSharedConfig.DebugLevel == 2 then targetDebug = true end
end
detectDebugEnabled()
local sleepless_interact = exports.sleepless_interact
local targetZones = {}
Target = Target or {}
---This is an internal function that is used to fix the options passed to fit alternative target systems, for example qb-ox or ox-qb etc.
---@param options table
---@return table
Target.FixOptions = function(options)
for k, v in pairs(options) do
local action = v.onSelect or v.action
local select = function(entityOrData)
if type(entityOrData) == 'table' then
return action(entityOrData.entity)
end
return action(entityOrData)
end
options[k].onSelect = select
end
return options
end
---This will toggle the targeting system on or off. This is useful for when you want to disable the targeting system for a specific player entirely.
---@param bool boolean
Target.DisableTargeting = function(bool) -- someone disabled this mistakenly
sleepless_interact:disableInteract(bool)
end
---This will add target options to players.
---@param options table
Target.AddGlobalPlayer = function(options)
options = Target.FixOptions(options)
sleepless_interact:addGlobalPlayer(options)
end
---This will remove target options from all players.
Target.RemoveGlobalPlayer = function()
sleepless_interact:removeGlobalPlayer()
end
---This will add target options to all specified models. This is useful for when you want to add target options to all models of a specific type.
---@param options table
Target.AddGlobalPed = function(options)
options = Target.FixOptions(options)
sleepless_interact:addGlobalPed(options)
end
---This will remove target options from all peds. This is useful for when you want to remove target options from all peds.
---@param options any
Target.RemoveGlobalPed = function(options)
sleepless_interact:removeGlobalPed(options)
end
---This will add taget options to all vehicles.
---@param options table
Target.AddGlobalVehicle = function(options)
options = Target.FixOptions(options)
sleepless_interact:addGlobalVehicle(options)
end
---This will remove target options from all vehicles.
---@param options table
Target.RemoveGlobalVehicle = function(options)
local assembledLables = {}
for k, v in pairs(options) do
table.insert(assembledLables, v.name)
end
sleepless_interact:removeGlobalVehicle(assembledLables)
end
---This will add a networked entity to the target system.
---@param netids table | number
---@param options table
Target.AddNetworkedEntity = function(netids, options)
options = Target.FixOptions(options)
sleepless_interact:addEntity(netids, options)
end
---This will remove a networked entity from the target system.
---@param netids table | number
---@param optionNames string
Target.RemoveNetworkedEntity = function(netids, optionNames)
sleepless_interact:removeEntity(netids, optionNames)
end
---This will generate targets on non networked entites with the passed options.
---@param entities number | table
---@param options table
Target.AddLocalEntity = function(entities, options)
options = Target.FixOptions(options)
sleepless_interact:addLocalEntity(entities, options)
end
---This will remove the target options from a local entity. This is useful for when you want to remove target options from a specific entity.
---@param entity number | table
---@param labels string | table | nil
Target.RemoveLocalEntity = function(entity, labels)
sleepless_interact:removeLocalEntity(entity, labels)
end
---This will add target options to all specified models. This is useful for when you want to add target options to all models of a specific type.
---@param models number | table
---@param options table
Target.AddModel = function(models, options)
options = Target.FixOptions(options)
sleepless_interact:addModel(models, options)
end
---This will remove target options from all specified models.
---@param model number
Target.RemoveModel = function(model)
sleepless_interact:removeModel(model)
end
---This will add a box zone to the target system. This is useful for when you want to add target options to a specific area.
---@param name string
---@param coords table
---@param size table
---@param heading number
---@param options table
Target.AddBoxZone = function(name, coords, size, heading, options)
options = Target.FixOptions(options)
local target = sleepless_interact:addCoords({
coords = coords,
options = options,
})
table.insert(targetZones, { name = name, id = target, creator = GetInvokingResource() })
return target
end
---This will add a circle zone to the target system. This is useful for when you want to add target options to a specific area.
---@param name string
---@param coords table
---@param radius number
---@param options table
Target.AddSphereZone = function(name, coords, radius, heading, options)
options = Target.FixOptions(options)
local target = sleepless_interact:addSphereZone({
coords = coords,
radius = radius,
name = name,
debug = targetDebug,
options = options
})
table.insert(targetZones, { name = name, id = target, creator = GetInvokingResource() })
return target
end
---This will remove target options from a specific zone.
---@param name string
Target.RemoveZone = function(name)
for _, data in pairs(targetZones) do
if data.name == name then
sleepless_interact:removeCoords(data.id)
table.remove(targetZones, _)
break
end
end
end
AddEventHandler('onResourceStop', function(resource)
if resource ~= GetCurrentResourceName() then return end
for _, target in pairs(targetZones) do
if target.creator == resource then
sleepless_interact:removeZone(target.id)
end
end
targetZones = {}
end)
return Target