diff --git a/modules/shops/_default/client.lua b/modules/shops/_default/client.lua index c8512db..a80f41f 100644 --- a/modules/shops/_default/client.lua +++ b/modules/shops/_default/client.lua @@ -1,3 +1,4 @@ +---@diagnostic disable: duplicate-set-field Shops = Shops or {} RegisterNetEvent('community_bridge:openShop', function(_type, _title, shopData) diff --git a/modules/shops/_default/server.lua b/modules/shops/_default/server.lua index dc5e7a3..c44b668 100644 --- a/modules/shops/_default/server.lua +++ b/modules/shops/_default/server.lua @@ -1,3 +1,4 @@ +---@diagnostic disable: duplicate-set-field Shops = Shops or {} local registeredShops = {} diff --git a/modules/target/_default/init.lua b/modules/target/_default/init.lua index d7a1e3f..fbce4cd 100644 --- a/modules/target/_default/init.lua +++ b/modules/target/_default/init.lua @@ -2,6 +2,7 @@ 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' } diff --git a/modules/target/ox_target/client.lua b/modules/target/ox_target/client.lua index 69a213e..ee67df0 100644 --- a/modules/target/ox_target/client.lua +++ b/modules/target/ox_target/client.lua @@ -34,6 +34,12 @@ Target.FixOptions = function(options) 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) @@ -43,14 +49,20 @@ end ---This will remove target options from all players. Target.RemoveGlobalPlayer = function() ----@diagnostic disable-next-line: missing-parameter ox_target:removeGlobalPlayer() 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) +---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. @@ -85,19 +97,6 @@ Target.RemoveLocalEntity = function(entities, optionNames) ox_target:removeLocalEntity(entities, 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 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 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 @@ -112,18 +111,6 @@ Target.RemoveModel = function(model) ox_target:removeModel(model) end --- Target.DisableTargeting = function(bool) --- ox_target:disableTargeting(bool) --- end - --- Target.Refresh = function() --- ox_target:disableTargeting(true) --- Wait(10) --- ox_target:disableTargeting(false) --- 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 @@ -144,19 +131,6 @@ Target.AddBoxZone = function(name, coords, size, heading, options, debug) return target end --- RegisterCommand('boxzone:test', function(source, args, rawCommand) --- local coords = GetEntityCoords(PlayerPedId()) --- Target.AddBoxZone('test_zone', coords, { 2.0, 2.0, 2.0 }, 0.0, { --- { --- label = 'Test Option', --- icon = 'fas fa-check', --- onSelect = function() --- print('Test option selected!') --- end --- } --- }, true) --- 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 diff --git a/modules/target/qb-target/client.lua b/modules/target/qb-target/client.lua index f990d8a..dcd3df1 100644 --- a/modules/target/qb-target/client.lua +++ b/modules/target/qb-target/client.lua @@ -57,6 +57,19 @@ 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) +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) @@ -95,20 +108,6 @@ 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 options table -Target.AddGlobalPed = function(options) - options = Target.FixOptions(options) - qb_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) - qb_target:RemoveGlobalPed(options) -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 @@ -126,17 +125,6 @@ Target.RemoveModel = function(model) qb_target:RemoveTargetModel(model) end --- Target.DisableTargeting = function(bool) --- qb_target:AllowTargeting(bool) --- end - --- Target.Refresh = function() --- qb_target:AllowTargeting(false) --- Wait(10) --- qb_target:AllowTargeting(true) --- 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 diff --git a/modules/target/sleepless_interact/client.lua b/modules/target/sleepless_interact/client.lua index b6011a7..a35c747 100644 --- a/modules/target/sleepless_interact/client.lua +++ b/modules/target/sleepless_interact/client.lua @@ -5,9 +5,7 @@ if GetResourceState("ox_target") == 'started' then return end local targetDebug = false local function detectDebugEnabled() - if BridgeSharedConfig.DebugLevel == 2 then - targetDebug = true - end + if BridgeSharedConfig.DebugLevel == 2 then targetDebug = true end end detectDebugEnabled() @@ -17,6 +15,9 @@ 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 @@ -31,29 +32,46 @@ Target.FixOptions = function(options) return options end ----comment +---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 ----@return nil Target.AddGlobalPlayer = function(options) options = Target.FixOptions(options) sleepless_interact:addGlobalPlayer(options) end -Target.DisableTargeting = function(bool) - sleepless_interact:disableInteract(bool) +---This will remove target options from all players. +Target.RemoveGlobalPlayer = function() + sleepless_interact:removeGlobalPlayer() end ----comment +---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 ----@return nil Target.AddGlobalVehicle = function(options) options = Target.FixOptions(options) sleepless_interact:addGlobalVehicle(options) end ----comment +---This will remove target options from all vehicles. ---@param options table ----@return nil Target.RemoveGlobalVehicle = function(options) local assembledLables = {} for k, v in pairs(options) do @@ -62,31 +80,41 @@ Target.RemoveGlobalVehicle = function(options) sleepless_interact:removeGlobalVehicle(assembledLables) end ----comment ----@param entities table +---This will generate targets on non networked entites with the passed options. +---@param entities number | table ---@param options table ----@return nil Target.AddLocalEntity = function(entities, options) options = Target.FixOptions(options) sleepless_interact:addLocalEntity(entities, options) end ----comment ----@param models table +---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 ----@return nil Target.AddModel = function(models, options) options = Target.FixOptions(options) sleepless_interact:addModel(models, options) end ----comment +---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 ----@return number Target.AddBoxZone = function(name, coords, size, heading, options) options = Target.FixOptions(options) local target = sleepless_interact:addCoords({ @@ -97,28 +125,26 @@ Target.AddBoxZone = function(name, coords, size, heading, options) return target end -Target.RemoveGlobalPlayer = function() - sleepless_interact:removeGlobalPlayer() -end - ----comment ----@param entity number ----@param labels string | table | nil ----@return nil -Target.RemoveLocalEntity = function(entity, labels) - sleepless_interact:removeLocalEntity(entity, labels) -end - ----comment ----@param model string ----@return nil -Target.RemoveModel = function(model) - sleepless_interact:removeModel(model) -end - ----comment +---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 ----@return nil Target.RemoveZone = function(name) for _, data in pairs(targetZones) do if data.name == name then @@ -129,26 +155,14 @@ Target.RemoveZone = function(name) end end --- Target.DisableTargeting = function(bool) --- sleepless_interact:disableInteract(bool) --- end - --- Target.Refresh = function() --- sleepless_interact:disableInteract(false) --- Wait(10) --- sleepless_interact:disableInteract(true) --- end - - AddEventHandler('onResourceStop', function(resource) - if resource == GetCurrentResourceName() then - for _, target in pairs(targetZones) do - if target.creator == resource then - sleepless_interact:removeZone(target.id) - end + if resource ~= GetCurrentResourceName() then return end + for _, target in pairs(targetZones) do + if target.creator == resource then + sleepless_interact:removeZone(target.id) end - targetZones = {} end + targetZones = {} end) return Target \ No newline at end of file