ed
This commit is contained in:
parent
875c8448e1
commit
c81ae4bb6d
219 changed files with 8036 additions and 7 deletions
27
resources/[tools]/bl_bridge/client/context/ox.lua
Normal file
27
resources/[tools]/bl_bridge/client/context/ox.lua
Normal file
|
@ -0,0 +1,27 @@
|
|||
local Context = {}
|
||||
local menu = exports.ox_lib
|
||||
|
||||
local function findHeader(data)
|
||||
for k, v in ipairs(data) do
|
||||
if v.isMenuHeader then
|
||||
return k, v.title
|
||||
end
|
||||
end
|
||||
return false, 'Header'
|
||||
end
|
||||
|
||||
---@param data ContextMenuProps | ContextMenuProps[]
|
||||
function Context.openContext(data)
|
||||
local id = require'utils'.await('UUID', false, 8)
|
||||
local index, header = findHeader(data)
|
||||
if index then table.remove(data, index) end
|
||||
menu:registerContext({id = id, title = header, options = data})
|
||||
menu:showContext(id)
|
||||
return id
|
||||
end
|
||||
|
||||
function Context.closeContext(onExit)
|
||||
menu:hideContext(onExit)
|
||||
end
|
||||
|
||||
return Context
|
66
resources/[tools]/bl_bridge/client/context/qb.lua
Normal file
66
resources/[tools]/bl_bridge/client/context/qb.lua
Normal file
|
@ -0,0 +1,66 @@
|
|||
local menuName = 'qb-menu'
|
||||
if GetResourceState(menuName) ~= 'started' then
|
||||
error('The imported file from the chosen framework isn\'t starting')
|
||||
return
|
||||
end
|
||||
|
||||
local Context = {}
|
||||
local qb_menu = exports[menuName]
|
||||
local Utils = require 'utils'
|
||||
|
||||
local overRideData = {
|
||||
header = {
|
||||
originalMethod = 'title',
|
||||
},
|
||||
txt = {
|
||||
originalMethod = 'description',
|
||||
},
|
||||
icon = {
|
||||
originalMethod = 'icon',
|
||||
modifier = {
|
||||
executeFunc = true,
|
||||
effect = function(value)
|
||||
local text = ('fas fa-%s'):format(value)
|
||||
return text
|
||||
end
|
||||
}
|
||||
},
|
||||
params = {
|
||||
originalMethod = 'none',
|
||||
hasKeys = true,
|
||||
modifier = {
|
||||
effect = function(data)
|
||||
local params = {}
|
||||
if data.onSelect then
|
||||
params.event = data.onSelect
|
||||
params.isAction = true
|
||||
elseif data.event then
|
||||
params.event = data.event
|
||||
params.args = data.args
|
||||
elseif data.serverEvent then
|
||||
params.event = data.serverEvent
|
||||
params.isServer = true
|
||||
params.args = data.args
|
||||
end
|
||||
return params
|
||||
end
|
||||
},
|
||||
},
|
||||
disabled = {
|
||||
originalMethod = 'disabled',
|
||||
},
|
||||
isMenuHeader = {
|
||||
originalMethod = 'isHeader',
|
||||
},
|
||||
}
|
||||
|
||||
---@param data ContextMenuProps | ContextMenuProps[]
|
||||
function Context.openContext(data)
|
||||
qb_menu:openMenu(Utils.retreiveNumberIndexedData(data, overRideData))
|
||||
end
|
||||
|
||||
function Context.closeContext()
|
||||
qb_menu:closeMenu()
|
||||
end
|
||||
|
||||
return Context
|
63
resources/[tools]/bl_bridge/client/core/esx.lua
Normal file
63
resources/[tools]/bl_bridge/client/core/esx.lua
Normal file
|
@ -0,0 +1,63 @@
|
|||
local coreName = 'es_extended'
|
||||
if GetResourceState(coreName) ~= 'started' then
|
||||
error('The imported file from the chosen framework isn\'t starting')
|
||||
return
|
||||
end
|
||||
|
||||
local Core = {}
|
||||
local retreiveStringIndexedData = require 'utils'.retreiveStringIndexedData
|
||||
|
||||
RegisterNetEvent('esx:playerLoaded', function(playerId)
|
||||
TriggerEvent('bl_bridge:client:playerLoaded', playerId)
|
||||
end)
|
||||
|
||||
RegisterNetEvent('esx:onPlayerLogout', function()
|
||||
TriggerEvent('bl_bridge:client:playerUnloaded')
|
||||
end)
|
||||
|
||||
RegisterNetEvent('esx:setJob', function(job)
|
||||
TriggerEvent('bl_bridge:client:jobUpdated', {name = job.name, label = job.label, onDuty = true, isBoss = false, grade = {name = job.grade, label = job.grade_label, salary = job.grade_salary}})
|
||||
end)
|
||||
|
||||
local shared = exports[coreName]:getSharedObject()
|
||||
|
||||
local coreFunctionsOverride = {
|
||||
playerData = {
|
||||
originalMethod = 'GetPlayerData',
|
||||
modifier = {
|
||||
executeFunc = true,
|
||||
effect = function(originalFun)
|
||||
while not shared.IsPlayerLoaded() do
|
||||
Wait(1000)
|
||||
end
|
||||
local data = originalFun()
|
||||
local job = data.job
|
||||
|
||||
local month, day, year = data.dateofbirth and data.dateofbirth:match("(%d+)/(%d+)/(%d+)") or 00, 00, 24
|
||||
|
||||
return {
|
||||
cid = data.identifier,
|
||||
money = data.money or 0,
|
||||
inventory = data.inventory or {},
|
||||
job = {name = job.name, label = job.label, onDuty = true, isBoss = false, grade = {name = job.grade, label = job.grade_label, salary = job.grade_salary}},
|
||||
firstName = data.firstName or 'Unknown',
|
||||
lastName = data.lastName or 'Unknown',
|
||||
phone = data.phone_number or '0',
|
||||
gender = data.sex == 'm' and 'male' or 'female',
|
||||
dob = ('%s/%s/%s'):format(month, day, year)
|
||||
}
|
||||
end
|
||||
}
|
||||
},
|
||||
}
|
||||
|
||||
function Core.getPlayerData()
|
||||
local wrappedPlayer = retreiveStringIndexedData(shared, coreFunctionsOverride)
|
||||
return wrappedPlayer.playerData
|
||||
end
|
||||
|
||||
function Core.playerLoaded()
|
||||
return shared.IsPlayerLoaded()
|
||||
end
|
||||
|
||||
return Core
|
74
resources/[tools]/bl_bridge/client/core/nd.lua
Normal file
74
resources/[tools]/bl_bridge/client/core/nd.lua
Normal file
|
@ -0,0 +1,74 @@
|
|||
local coreName = 'ND_Core'
|
||||
if GetResourceState(coreName) ~= 'started' then
|
||||
error('The imported file from the chosen framework isn\'t starting')
|
||||
return
|
||||
end
|
||||
|
||||
local Core = {}
|
||||
local retreiveStringIndexedData = require 'utils'.retreiveStringIndexedData
|
||||
local jobInfo = {}
|
||||
local loaded = false
|
||||
|
||||
RegisterNetEvent('ND:characterLoaded', function(character)
|
||||
TriggerEvent('bl_bridge:client:playerLoaded')
|
||||
jobInfo = character.jobInfo
|
||||
jobInfo.name = character.job
|
||||
loaded = true
|
||||
Wait(1000)
|
||||
end)
|
||||
|
||||
AddEventHandler("ND:characterUnloaded", function(character)
|
||||
TriggerEvent('bl_bridge:client:playerUnloaded')
|
||||
jobInfo = {}
|
||||
loaded = false
|
||||
end)
|
||||
|
||||
RegisterNetEvent('ND:updateCharacter', function(character)
|
||||
local jobData = character.jobInfo
|
||||
if character.job ~= jobInfo.name or jobInfo.rank ~= jobData.rank then
|
||||
TriggerEvent('bl_bridge:client:jobUpdated', { name = character.job, label = jobData.label, onDuty = true, isBoss = jobData.isBoss or false, grade = { name = jobData.rank, label = jobData.rankName, salary = 0 } })
|
||||
end
|
||||
end)
|
||||
|
||||
local shared = exports[coreName]
|
||||
|
||||
local coreFunctionsOverride = {
|
||||
playerData = {
|
||||
originalMethod = 'getPlayer',
|
||||
modifier = {
|
||||
executeFunc = true,
|
||||
effect = function(originalFun)
|
||||
while not loaded do
|
||||
Wait(1000)
|
||||
end
|
||||
local data = originalFun()
|
||||
local jobData = data.jobInfo
|
||||
|
||||
local year, month, day = data.dob:match("(%d+)-(%d+)-(%d+)")
|
||||
|
||||
return {
|
||||
cid = data.id,
|
||||
money = data.cash,
|
||||
inventory = type(data.inventory) == 'string' and json.decode(data.inventory) or data.inventory,
|
||||
job = { name = data.job, label = jobData.label, onDuty = true, isBoss = jobData.isBoss, grade = { name = jobData.rank, label = jobData.rankName, salary = 0 } },
|
||||
firstName = data.firstname,
|
||||
lastName = data.lastname,
|
||||
phone = 'Unknown',
|
||||
gender = string.lower(data.gender),
|
||||
dob = ('%s/%s/%s'):format(month, day, year),
|
||||
}
|
||||
end
|
||||
}
|
||||
},
|
||||
}
|
||||
|
||||
function Core.getPlayerData()
|
||||
local wrappedPlayer = retreiveStringIndexedData(shared, coreFunctionsOverride)
|
||||
return wrappedPlayer.playerData
|
||||
end
|
||||
|
||||
function Core.playerLoaded()
|
||||
return loaded
|
||||
end
|
||||
|
||||
return Core
|
69
resources/[tools]/bl_bridge/client/core/ox.lua
Normal file
69
resources/[tools]/bl_bridge/client/core/ox.lua
Normal file
|
@ -0,0 +1,69 @@
|
|||
local Ox = require '@ox_core/lib/init'
|
||||
local Core = {}
|
||||
local retreiveStringIndexedData = require 'utils'.retreiveStringIndexedData
|
||||
LocalPlayer.state.isLoggedIn = true
|
||||
|
||||
AddEventHandler('ox:playerLoaded', function()
|
||||
TriggerEvent('bl_bridge:client:playerLoaded')
|
||||
LocalPlayer.state.isLoggedIn = true
|
||||
end)
|
||||
|
||||
RegisterNetEvent('bl_bridge:client:playerUnloaded',function()
|
||||
LocalPlayer.state.isLoggedIn = false
|
||||
end)
|
||||
|
||||
local function prepareJobData(job, grade)
|
||||
return {name = job.name, label = job.label, onDuty = true, isBoss = job.accountRoles[tostring(grade)] == 'owner', type = job.type, grade = { name = grade, label = job.grades[grade], salary = 0 } }
|
||||
end
|
||||
|
||||
RegisterNetEvent('ox:setGroup', function(groupName, grade)
|
||||
local job = Ox.GetGroup(groupName)
|
||||
TriggerEvent('bl_bridge:client:jobUpdated', prepareJobData(job, grade))
|
||||
end)
|
||||
|
||||
local coreFunctionsOverride = {
|
||||
playerData = {
|
||||
originalMethod = 'GetPlayer',
|
||||
modifier = {
|
||||
executeFunc = true,
|
||||
effect = function(originalFun) -- TODO: lazy loading for all data, only return what need, others can be requested like get(key)
|
||||
while not LocalPlayer.state.isLoggedIn do
|
||||
Wait(1000)
|
||||
end
|
||||
local data = originalFun()
|
||||
---@type function
|
||||
local get = data.get
|
||||
local activeJob = get('activeGroup')
|
||||
if not activeJob then return end
|
||||
|
||||
local grade = data.getGroup(activeJob)
|
||||
local job = Ox.GetGroup(activeJob)
|
||||
local group = prepareJobData(job, grade)
|
||||
|
||||
return {
|
||||
cid = data.citizenid,
|
||||
money = data.money or 0,
|
||||
inventory = exports.ox_inventory:GetPlayerItems(),
|
||||
job = group,
|
||||
gang = group,
|
||||
firstName = get('firstName') or 'Unknown',
|
||||
lastName = get('lastName') or 'Unknown',
|
||||
phone = get('phoneNumber') or '0000000',
|
||||
gender = get('gender'),
|
||||
dob = get('dateOfBirth') -- DD/MM/YYYY
|
||||
}
|
||||
end
|
||||
}
|
||||
},
|
||||
}
|
||||
|
||||
function Core.getPlayerData()
|
||||
local wrappedPlayer = retreiveStringIndexedData(Ox, coreFunctionsOverride)
|
||||
return wrappedPlayer.playerData
|
||||
end
|
||||
|
||||
function Core.playerLoaded()
|
||||
return LocalPlayer.state.isLoggedIn
|
||||
end
|
||||
|
||||
return Core
|
71
resources/[tools]/bl_bridge/client/core/qb.lua
Normal file
71
resources/[tools]/bl_bridge/client/core/qb.lua
Normal file
|
@ -0,0 +1,71 @@
|
|||
local coreName = 'qb-core'
|
||||
if GetResourceState(coreName) ~= 'started' then
|
||||
error('The imported file from the chosen framework isn\'t starting')
|
||||
return
|
||||
end
|
||||
|
||||
local Core = {}
|
||||
local retreiveStringIndexedData = require 'utils'.retreiveStringIndexedData
|
||||
|
||||
AddEventHandler('QBCore:Client:OnPlayerLoaded', function()
|
||||
TriggerEvent('bl_bridge:client:playerLoaded')
|
||||
end)
|
||||
|
||||
RegisterNetEvent('QBCore:Client:OnPlayerUnload', function()
|
||||
TriggerEvent('bl_bridge:client:playerUnloaded')
|
||||
end)
|
||||
|
||||
RegisterNetEvent('QBCore:Client:OnJobUpdate', function(job)
|
||||
TriggerEvent('bl_bridge:client:jobUpdated', { name = job.name, label = job.label, onDuty = job.onduty, type = job.type, isBoss = job.isboss, grade = { name = job.grade.level, label = job.grade.name, salary = job.payment } })
|
||||
end)
|
||||
|
||||
RegisterNetEvent('QBCore:Client:OnGangUpdate', function(gang)
|
||||
TriggerEvent('bl_bridge:client:gangUpdated', { name = gang.name, label = gang.label, isBoss = gang.isboss, grade = { name = gang.grade.level, label = gang.grade.label } })
|
||||
end)
|
||||
|
||||
local shared = exports[coreName]:GetCoreObject()
|
||||
|
||||
local coreFunctionsOverride = {
|
||||
Functions = {
|
||||
playerData = {
|
||||
originalMethod = 'GetPlayerData',
|
||||
modifier = {
|
||||
executeFunc = true,
|
||||
effect = function(originalFun)
|
||||
while not LocalPlayer.state.isLoggedIn do
|
||||
Wait(1000)
|
||||
end
|
||||
local data = originalFun()
|
||||
local job = data.job
|
||||
local gang = data.gang
|
||||
local charinfo = data.charinfo
|
||||
|
||||
local year, month, day = charinfo.birthdate:match("(%d+)-(%d+)-(%d+)")
|
||||
return {
|
||||
cid = data.citizenid,
|
||||
money = data.money or 0,
|
||||
inventory = type(data.items) == 'string' and json.decode(data.items) or data.items,
|
||||
job = { name = job.name, label = job.label, onDuty = job.onduty, isBoss = job.isboss, type = job.type, grade = { name = job.grade.level, label = job.grade.name, salary = job.payment } },
|
||||
gang = { name = gang.name, label = gang.label, isBoss = gang.isboss, grade = { name = gang.grade.level, label = gang.grade.label } },
|
||||
firstName = charinfo.firstname or 'Unknown',
|
||||
lastName = charinfo.lastname or 'Unknown',
|
||||
phone = charinfo.phone or '0000000',
|
||||
gender = charinfo.gender == 1 and 'female' or 'male',
|
||||
dob = ('%s/%s/%s'):format(month, day, year) -- DD/MM/YYYY
|
||||
}
|
||||
end
|
||||
}
|
||||
},
|
||||
},
|
||||
}
|
||||
|
||||
function Core.getPlayerData()
|
||||
local wrappedPlayer = retreiveStringIndexedData(shared, coreFunctionsOverride)
|
||||
return wrappedPlayer.playerData
|
||||
end
|
||||
|
||||
function Core.playerLoaded()
|
||||
return LocalPlayer.state.isLoggedIn
|
||||
end
|
||||
|
||||
return Core
|
69
resources/[tools]/bl_bridge/client/core/qbx.lua
Normal file
69
resources/[tools]/bl_bridge/client/core/qbx.lua
Normal file
|
@ -0,0 +1,69 @@
|
|||
local coreName = 'qbx_core'
|
||||
if GetResourceState(coreName) ~= 'started' then
|
||||
error('The imported file from the chosen framework isn\'t starting')
|
||||
return
|
||||
end
|
||||
|
||||
local Core = {}
|
||||
local retreiveStringIndexedData = require 'utils'.retreiveStringIndexedData
|
||||
|
||||
AddEventHandler('QBCore:Client:OnPlayerLoaded', function()
|
||||
TriggerEvent('bl_bridge:client:playerLoaded')
|
||||
end)
|
||||
|
||||
RegisterNetEvent('QBCore:Client:OnPlayerUnload', function()
|
||||
TriggerEvent('bl_bridge:client:playerUnloaded')
|
||||
end)
|
||||
|
||||
RegisterNetEvent('QBCore:Client:OnJobUpdate', function(job)
|
||||
TriggerEvent('bl_bridge:client:jobUpdated', { name = job.name, label = job.label, onDuty = job.onduty, type = job.type, isBoss = job.isboss, grade = { name = job.grade.level, label = job.grade.name, salary = job.payment } })
|
||||
end)
|
||||
|
||||
RegisterNetEvent('QBCore:Client:OnGangUpdate', function(gang)
|
||||
TriggerEvent('bl_bridge:client:gangUpdated', { name = gang.name, label = gang.label, isBoss = gang.isboss, grade = { name = gang.grade.level, label = gang.grade.label } })
|
||||
end)
|
||||
|
||||
local shared = exports[coreName]
|
||||
|
||||
local coreFunctionsOverride = {
|
||||
playerData = {
|
||||
originalMethod = 'GetPlayerData',
|
||||
modifier = {
|
||||
executeFunc = true,
|
||||
effect = function(originalFun)
|
||||
while not LocalPlayer.state.isLoggedIn do
|
||||
Wait(1000)
|
||||
end
|
||||
local data = originalFun()
|
||||
local job = data.job
|
||||
local gang = data.gang
|
||||
local charinfo = data.charinfo
|
||||
|
||||
local year, month, day = charinfo.birthdate:match("(%d+)-(%d+)-(%d+)")
|
||||
return {
|
||||
cid = data.citizenid,
|
||||
money = data.money or 0,
|
||||
inventory = type(data.items) == 'string' and json.decode(data.items) or data.items,
|
||||
job = { name = job.name, label = job.label, onDuty = job.onduty, isBoss = job.isboss, type = job.type, grade = { name = job.grade.level, label = job.grade.name, salary = job.payment } },
|
||||
gang = { name = gang.name, label = gang.label, isBoss = gang.isboss, grade = { name = gang.grade.level, label = gang.grade.label } },
|
||||
firstName = charinfo.firstname or 'Unknown',
|
||||
lastName = charinfo.lastname or 'Unknown',
|
||||
phone = charinfo.phone or '0000000',
|
||||
gender = charinfo.gender == 1 and 'female' or 'male',
|
||||
dob = ('%s/%s/%s'):format(month, day, year) -- DD/MM/YYYY
|
||||
}
|
||||
end
|
||||
}
|
||||
},
|
||||
}
|
||||
|
||||
function Core.getPlayerData()
|
||||
local wrappedPlayer = retreiveStringIndexedData(shared, coreFunctionsOverride)
|
||||
return wrappedPlayer.playerData
|
||||
end
|
||||
|
||||
function Core.playerLoaded()
|
||||
return LocalPlayer.state.isLoggedIn
|
||||
end
|
||||
|
||||
return Core
|
75
resources/[tools]/bl_bridge/client/inventory/all.lua
Normal file
75
resources/[tools]/bl_bridge/client/inventory/all.lua
Normal file
|
@ -0,0 +1,75 @@
|
|||
local inventory = {}
|
||||
local invFramework = GetFramework('inventory')
|
||||
local Utils = require'utils'
|
||||
local isOx = invFramework == 'ox_inventory'
|
||||
local isOrigen = invFramework == 'origen_inventory'
|
||||
local isQS = invFramework == 'qs-inventory'
|
||||
|
||||
-- function inventory.items()
|
||||
-- local inventoryItems = isOx and exports.ox_inventory:Items() or core.getPlayerData().items or {}
|
||||
-- return inventoryItems
|
||||
-- end
|
||||
|
||||
function inventory.playerItems()
|
||||
local playerData = {}
|
||||
if isOx then
|
||||
playerData = exports.ox_inventory:GetPlayerItems()
|
||||
elseif isOrigen then
|
||||
playerData = exports.origen_inventory:GetInventory()
|
||||
elseif isQS then
|
||||
playerData = exports['qs-inventory']:getUserInventory()
|
||||
else
|
||||
local core = Framework.core
|
||||
if not core then
|
||||
Utils.waitFor(function()
|
||||
if Framework.core then return true end
|
||||
end)
|
||||
end
|
||||
playerData = core.getPlayerData().inventory
|
||||
end
|
||||
|
||||
for _, itemData in pairs(playerData) do
|
||||
local count = itemData.count
|
||||
if count then
|
||||
itemData.amount = count
|
||||
itemData.count = nil
|
||||
end
|
||||
end
|
||||
return playerData
|
||||
end
|
||||
|
||||
function inventory.openInventory(invType, invId)
|
||||
if isOx then
|
||||
exports.ox_inventory:openInventory(invType, invType == 'stash' and invId or {type = invId})
|
||||
elseif isOrigen then
|
||||
exports.origen_inventory:openInventory(invType, invId)
|
||||
|
||||
elseif invFramework == 'qb-inventory' or isQS then
|
||||
local inventoryData = Utils.await('bl_bridge:validInventory', 10, invType, invId)
|
||||
if not inventoryData then return end
|
||||
TriggerServerEvent('inventory:server:OpenInventory', invType, invId, inventoryData)
|
||||
end
|
||||
end
|
||||
|
||||
function inventory.hasItem(itemName, itemCount)
|
||||
itemCount = itemCount or 1
|
||||
local playerData = inventory.playerItems()
|
||||
local notify = Framework.notify
|
||||
|
||||
if type(itemName) ~= 'string' then
|
||||
notify({
|
||||
title = 'item isn\'t string'
|
||||
})
|
||||
return
|
||||
end
|
||||
|
||||
for _, itemData in pairs(playerData) do
|
||||
local name, amount in itemData
|
||||
if itemName == name and itemCount <= amount then
|
||||
return true
|
||||
end
|
||||
end
|
||||
return false
|
||||
end
|
||||
|
||||
return inventory
|
10
resources/[tools]/bl_bridge/client/notify/esx.lua
Normal file
10
resources/[tools]/bl_bridge/client/notify/esx.lua
Normal file
|
@ -0,0 +1,10 @@
|
|||
---@diagnostic disable: lowercase-global
|
||||
|
||||
---@param data NotificationParams Notification data
|
||||
function notify(data)
|
||||
local title, type, duration in data
|
||||
if type == 'inform' then type = 'info' end
|
||||
exports.es_extended:getSharedObject().ShowNotification(title, type, duration)
|
||||
end
|
||||
|
||||
return notify
|
8
resources/[tools]/bl_bridge/client/notify/ox.lua
Normal file
8
resources/[tools]/bl_bridge/client/notify/ox.lua
Normal file
|
@ -0,0 +1,8 @@
|
|||
---@diagnostic disable: lowercase-global
|
||||
|
||||
---@param data NotificationParams Notification data
|
||||
function notify(data)
|
||||
exports.ox_lib:notify(data)
|
||||
end
|
||||
|
||||
return notify
|
10
resources/[tools]/bl_bridge/client/notify/qb.lua
Normal file
10
resources/[tools]/bl_bridge/client/notify/qb.lua
Normal file
|
@ -0,0 +1,10 @@
|
|||
---@diagnostic disable: lowercase-global
|
||||
|
||||
---@param data NotificationParams Notification data
|
||||
function notify(data)
|
||||
local title, type, duration in data
|
||||
if type == 'inform' then type = 'info' end
|
||||
TriggerEvent('QBCore:Notify', title, type, duration)
|
||||
end
|
||||
|
||||
return notify
|
28
resources/[tools]/bl_bridge/client/progressbar/ox.lua
Normal file
28
resources/[tools]/bl_bridge/client/progressbar/ox.lua
Normal file
|
@ -0,0 +1,28 @@
|
|||
local Progressbar = {}
|
||||
|
||||
function Progressbar.showProgress(data)
|
||||
return exports.ox_lib:progressBar({
|
||||
duration = data.duration,
|
||||
label = data.label,
|
||||
useWhileDead = data.useWhileDead,
|
||||
canCancel = data.canCancel,
|
||||
disable = data.disableControl,
|
||||
anim = data.animation,
|
||||
prop = {
|
||||
model = data.prop?.model,
|
||||
bone = data.prop?.bone,
|
||||
pos = data.prop?.pos,
|
||||
rot = data.prop?.rot
|
||||
},
|
||||
})
|
||||
end
|
||||
|
||||
function Progressbar.cancelProgress()
|
||||
exports.ox_lib:cancelProgress()
|
||||
end
|
||||
|
||||
function Progressbar.isProgressActive()
|
||||
return exports.ox_lib:progressActive()
|
||||
end
|
||||
|
||||
return Progressbar
|
52
resources/[tools]/bl_bridge/client/progressbar/qb.lua
Normal file
52
resources/[tools]/bl_bridge/client/progressbar/qb.lua
Normal file
|
@ -0,0 +1,52 @@
|
|||
local Progressbar = {}
|
||||
Progressbar.state = false
|
||||
|
||||
function Progressbar.showProgress(data)
|
||||
local prop, animation, disableControl in data
|
||||
local promise = promise.new()
|
||||
disableControl = disableControl or {}
|
||||
|
||||
exports['progressbar']:Progress({
|
||||
name = 'progress',
|
||||
duration = data.duration,
|
||||
label = data.label,
|
||||
useWhileDead = data.useWhileDead,
|
||||
canCancel = data.canCancel,
|
||||
controlDisables = {
|
||||
disableMovement = disableControl.move ~= false,
|
||||
disableCarMovement = disableControl.car ~= false,
|
||||
disableMouse = disableControl.mouse ~= false,
|
||||
disableCombat = disableControl.combat ~= false,
|
||||
},
|
||||
animation = animation and {
|
||||
animDict = animation.dict,
|
||||
anim = animation.clip,
|
||||
flags = animation.flag
|
||||
},
|
||||
prop = prop and {
|
||||
model = prop.model,
|
||||
bone = prop.bone,
|
||||
coords = prop.pos,
|
||||
rotation = prop.rot
|
||||
},
|
||||
}, function(cancelled)
|
||||
promise:resolve(not cancelled)
|
||||
end)
|
||||
local success = Citizen.Await(promise)
|
||||
|
||||
return success
|
||||
end
|
||||
|
||||
function Progressbar.cancelProgress()
|
||||
TriggerEvent("progressbar:client:cancel")
|
||||
end
|
||||
|
||||
function Progressbar.isProgressActive()
|
||||
return Progressbar.state
|
||||
end
|
||||
|
||||
RegisterNetEvent('progressbar:setstatus', function (state)
|
||||
Progressbar.state = state
|
||||
end)
|
||||
|
||||
return Progressbar
|
28
resources/[tools]/bl_bridge/client/radial/ox.lua
Normal file
28
resources/[tools]/bl_bridge/client/radial/ox.lua
Normal file
|
@ -0,0 +1,28 @@
|
|||
local Radial = {}
|
||||
|
||||
|
||||
function Radial.addOptions(optionId, data)
|
||||
local id = require'utils'.await('UUID', false, 8)
|
||||
local lib = exports.ox_lib
|
||||
|
||||
local title, icon, items in data
|
||||
lib:registerRadial({
|
||||
id = id,
|
||||
items = items
|
||||
})
|
||||
|
||||
lib:addRadialItem({
|
||||
{
|
||||
id = optionId,
|
||||
label = title or 'Unknown',
|
||||
icon = icon or 'hand',
|
||||
menu = id
|
||||
},
|
||||
})
|
||||
end
|
||||
|
||||
function Radial.removeOption(onExit)
|
||||
|
||||
end
|
||||
|
||||
return Radial
|
74
resources/[tools]/bl_bridge/client/radial/qb.lua
Normal file
74
resources/[tools]/bl_bridge/client/radial/qb.lua
Normal file
|
@ -0,0 +1,74 @@
|
|||
local menuName = 'qb-radialmenu'
|
||||
if GetResourceState(menuName) ~= 'started' then
|
||||
error(menuName..' isn\'t starting')
|
||||
return
|
||||
end
|
||||
|
||||
local qb_radial = exports[menuName]
|
||||
local Radial = {}
|
||||
local Utils = require 'utils'
|
||||
local eventIndex = 0
|
||||
local storedEvents = {}
|
||||
|
||||
local overRideData = {
|
||||
title = {
|
||||
originalMethod = 'label',
|
||||
},
|
||||
icon = {
|
||||
originalMethod = 'icon',
|
||||
},
|
||||
id = {
|
||||
originalMethod = 'menu',
|
||||
},
|
||||
shouldClose = {
|
||||
originalMethod = 'keepOpen',
|
||||
modifier = {
|
||||
executeFunc = true,
|
||||
effect = function(value)
|
||||
return type(value) ~= 'boolean' and true or not value
|
||||
end
|
||||
}
|
||||
},
|
||||
event = {
|
||||
originalMethod = 'onSelect',
|
||||
modifier = {
|
||||
executeFunc = true,
|
||||
effect = function(value)
|
||||
local eventName = ("bl_bridge:client:radialId%s"):format(eventIndex)
|
||||
eventIndex+= 1
|
||||
return {eventName = eventName, eventId = AddEventHandler(eventName, value)}
|
||||
end
|
||||
}
|
||||
},
|
||||
}
|
||||
|
||||
function Radial.addOptions(optionId, data)
|
||||
local id = Utils.await('UUID', false, 8)
|
||||
|
||||
local title, icon, items in data
|
||||
items = Utils.retreiveNumberIndexedData(items, overRideData)
|
||||
for _,v in ipairs(items) do
|
||||
v.type = 'client'
|
||||
|
||||
if v.event then
|
||||
local eventName, eventId in v.event
|
||||
local menuId = v.menu or #storedEvents+1
|
||||
storedEvents[menuId] = eventId
|
||||
|
||||
v.menu = menuId
|
||||
v.event = eventName
|
||||
end
|
||||
end
|
||||
qb_radial:AddOption({
|
||||
id = optionId,
|
||||
title = title or 'Unknown',
|
||||
icon = icon or 'hand',
|
||||
items = items
|
||||
}, id)
|
||||
end
|
||||
|
||||
function Radial.removeOption(onExit)
|
||||
|
||||
end
|
||||
|
||||
return Radial
|
177
resources/[tools]/bl_bridge/client/target/ox.lua
Normal file
177
resources/[tools]/bl_bridge/client/target/ox.lua
Normal 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
|
204
resources/[tools]/bl_bridge/client/target/qb.lua
Normal file
204
resources/[tools]/bl_bridge/client/target/qb.lua
Normal 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
|
23
resources/[tools]/bl_bridge/client/textui/esx.lua
Normal file
23
resources/[tools]/bl_bridge/client/textui/esx.lua
Normal file
|
@ -0,0 +1,23 @@
|
|||
---@diagnostic disable: lowercase-global
|
||||
local esx_textui = exports['esx_textui']
|
||||
local open = false
|
||||
local textui = {}
|
||||
|
||||
---@param text string
|
||||
---@param position? TextUIOptions
|
||||
function textui.showTextUI(text, position)
|
||||
esx_textui:TextUI(text)
|
||||
open = true
|
||||
end
|
||||
|
||||
function textui.hideTextUI()
|
||||
open = false
|
||||
esx_textui:HideUI()
|
||||
end
|
||||
|
||||
---@return boolean
|
||||
function textui.isTextUIOpen()
|
||||
return open
|
||||
end
|
||||
|
||||
return textui
|
19
resources/[tools]/bl_bridge/client/textui/ox.lua
Normal file
19
resources/[tools]/bl_bridge/client/textui/ox.lua
Normal file
|
@ -0,0 +1,19 @@
|
|||
---@diagnostic disable: lowercase-global
|
||||
|
||||
local textui = {}
|
||||
|
||||
---@param text string
|
||||
function textui.showTextUI(text, position)
|
||||
exports.ox_lib:showTextUI(text, position and {position = ('%s-center'):format(position)})
|
||||
end
|
||||
|
||||
function textui.hideTextUI()
|
||||
exports.ox_lib:hideTextUI()
|
||||
end
|
||||
|
||||
---@return boolean
|
||||
function textui.isTextUIOpen()
|
||||
return exports.ox_lib:isTextUIOpen()
|
||||
end
|
||||
|
||||
return textui
|
24
resources/[tools]/bl_bridge/client/textui/qb.lua
Normal file
24
resources/[tools]/bl_bridge/client/textui/qb.lua
Normal file
|
@ -0,0 +1,24 @@
|
|||
---@diagnostic disable: lowercase-global
|
||||
local textui_fw = 'qb-core'
|
||||
local qb_textui = exports[textui_fw]
|
||||
local open = false
|
||||
local textui = {}
|
||||
|
||||
---@param text string
|
||||
---@param position? TextUIOptions
|
||||
function textui.showTextUI(text, position)
|
||||
qb_textui:DrawText(text, position or 'right')
|
||||
open = true
|
||||
end
|
||||
|
||||
function textui.hideTextUI()
|
||||
open = false
|
||||
qb_textui:HideText()
|
||||
end
|
||||
|
||||
---@return boolean
|
||||
function textui.isTextUIOpen()
|
||||
return open
|
||||
end
|
||||
|
||||
return textui
|
Loading…
Add table
Add a link
Reference in a new issue