Targets, entities and events, oh my!
Targets updated to have boxzone Entities dont require a model and are effectively points with on spawn on despawn onplayerloaded and onplayeriunloaded now pass source
This commit is contained in:
1 parent
3a141cb8f2
commit
34d24cb6a9
11 files changed
+61
-352
No files matched your search
@@ -432,13 +432,13 @@ Framework.RegisterUsableItem = function(itemName, cb)
|
||||
ESX.RegisterUsableItem(itemName, func)
|
||||
end
|
||||
|
||||
RegisterNetEvent("esx:playerLoaded", function()
|
||||
local src = source
|
||||
RegisterNetEvent("esx:playerLoaded", function(src)
|
||||
src = src or source
|
||||
TriggerEvent("community_bridge:Server:OnPlayerLoaded", src)
|
||||
end)
|
||||
|
||||
RegisterNetEvent("esx:playerLogout", function()
|
||||
local src = source
|
||||
RegisterNetEvent("esx:playerLogout", function(src)
|
||||
src = src or source
|
||||
TriggerEvent("community_bridge:Server:OnPlayerUnload", src)
|
||||
end)
|
||||
|
||||
|
||||
@@ -562,13 +562,13 @@ Framework.RegisterUsableItem = function(itemName, cb)
|
||||
QBCore.Functions.CreateUseableItem(itemName, func)
|
||||
end
|
||||
|
||||
RegisterNetEvent("QBCore:Server:OnPlayerLoaded", function()
|
||||
local src = source
|
||||
RegisterNetEvent("QBCore:Server:OnPlayerLoaded", function(src)
|
||||
src = src or source
|
||||
TriggerEvent("community_bridge:Server:OnPlayerLoaded", src)
|
||||
end)
|
||||
|
||||
RegisterNetEvent("QBCore:Server:OnPlayerUnload", function(source)
|
||||
local src = source
|
||||
RegisterNetEvent("QBCore:Server:OnPlayerUnload", function(src)
|
||||
src = src or source
|
||||
TriggerEvent("community_bridge:Server:OnPlayerUnload", src)
|
||||
end)
|
||||
|
||||
|
||||
@@ -471,13 +471,13 @@ Framework.RegisterUsableItem = function(itemName, cb)
|
||||
return QBox:CreateUseableItem(itemName, func)
|
||||
end
|
||||
|
||||
RegisterNetEvent("QBCore:Server:OnPlayerLoaded", function()
|
||||
local src = source
|
||||
RegisterNetEvent("QBCore:Server:OnPlayerLoaded", function(src)
|
||||
src = src or source
|
||||
TriggerEvent("community_bridge:Server:OnPlayerLoaded", src)
|
||||
end)
|
||||
|
||||
RegisterNetEvent("QBCore:Server:OnPlayerUnload", function()
|
||||
local src = source
|
||||
RegisterNetEvent("QBCore:Server:OnPlayerUnload", function(src)
|
||||
src = src or source
|
||||
TriggerEvent("community_bridge:Server:OnPlayerUnload", src)
|
||||
end)
|
||||
|
||||
|
||||
@@ -102,19 +102,32 @@ end
|
||||
---@param size table
|
||||
---@param heading number
|
||||
---@param options table
|
||||
Target.AddBoxZone = function(name, coords, size, heading, options)
|
||||
options = Target.FixOptions(options)
|
||||
Target.AddBoxZone = function(name, coords, size, heading, options, debug)
|
||||
options = Target.FixOptions(options or {})
|
||||
local target = ox_target:addBoxZone({
|
||||
coords = coords,
|
||||
size = size,
|
||||
rotation = heading,
|
||||
debug = targetDebug,
|
||||
debug = debug or targetDebug,
|
||||
options = options,
|
||||
})
|
||||
table.insert(targetZones, { name = name, id = target, creator = GetInvokingResource() })
|
||||
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
|
||||
|
||||
@@ -66,7 +66,7 @@ Target.AddGlobalVehicle = function(options)
|
||||
})
|
||||
end
|
||||
|
||||
---This will remove target options from all vehicles.
|
||||
---This will remove target options from all vehicles.
|
||||
---@param options table
|
||||
Target.RemoveGlobalVehicle = function(options)
|
||||
local assembledLables = {}
|
||||
@@ -116,14 +116,14 @@ end
|
||||
---@param size table
|
||||
---@param heading number
|
||||
---@param options table
|
||||
Target.AddBoxZone = function(name, coords, size, heading, options)
|
||||
Target.AddBoxZone = function(name, coords, size, heading, options, debug)
|
||||
options = Target.FixOptions(options)
|
||||
qb_target:AddBoxZone(name, coords, size.x, size.y, {
|
||||
name = name,
|
||||
debugPoly = targetDebug,
|
||||
debugPoly = debug or targetDebug,
|
||||
heading = heading,
|
||||
minZ = coords.z - (size.x * 0.5),
|
||||
maxZ = coords.z + (size.x * 0.5),
|
||||
minZ = coords.z - (size.z * 0.5),
|
||||
maxZ = coords.z + (size.z * 0.5),
|
||||
}, {
|
||||
options = options,
|
||||
distance = options.distance or 1.5,
|
||||
|
||||
Reference in new issue
Block a user