add support for older QBCore GetPlayer event

This commit is contained in:
Jim Shield
2024-01-17 23:36:45 +00:00
committed by GitHub
parent 6c38f90b9a
commit 409c181cb2

View File

@@ -960,8 +960,9 @@ function createUseableItem(item, funct)
end end
end end
function hasJob(job, src, grade) local hasJob = false function hasJob(job, source, grade) local hasJob = false
if src then if source then
local src = tonumber(source)
if GetResourceState(ESXExport):find("start") then if GetResourceState(ESXExport):find("start") then
local info = ESX.GetPlayerFromId(src).job local info = ESX.GetPlayerFromId(src).job
while not info do while not info do
@@ -989,16 +990,31 @@ function hasJob(job, src, grade) local hasJob = false
hasJob = true hasJob = true
if grade and not (grade <= ganginfo.grade.level) then hasJob = false end if grade and not (grade <= ganginfo.grade.level) then hasJob = false end
end end
else elseif GetResourceState(QBExport):find("start") and not GetResourceState(QBXExport):find("start") then
local jobinfo = exports[QBExport]:GetPlayer(src).PlayerData.job if Core.Functions.GetPlayer ~= nil then -- support older qb-core
if jobinfo.name == job then local Player = Core.Functions.GetPlayer(src).PlayerData
hasJob = true
if grade and not (grade <= jobinfo.grade.level) then hasJob = false end local jobinfo = Player.job
end if jobinfo.name == job then
local ganginfo = exports[QBExport]:GetPlayer(src).PlayerData.gang hasJob = true
if ganginfo.name == job then if grade and not (grade <= jobinfo.grade.level) then hasJob = false end
hasJob = true end
if grade and not (grade <= ganginfo.grade.level) then hasJob = false end local ganginfo = Player.gang
if ganginfo.name == job then
hasJob = true
if grade and not (grade <= ganginfo.grade.level) then hasJob = false end
end
else
local jobinfo = Core.Functions.GetPlayer(src).PlayerData.job
if jobinfo.name == job then
hasJob = true
if grade and not (grade <= jobinfo.grade.level) then hasJob = false end
end
local ganginfo = Core.Functions.GetPlayer(src).PlayerData.gang
if ganginfo.name == job then
hasJob = true
if grade and not (grade <= ganginfo.grade.level) then hasJob = false end
end
end end
end end
else else