more old qbcore updates

This commit is contained in:
Jim Shield
2024-01-17 23:38:28 +00:00
committed by GitHub
parent 409c181cb2
commit 7094bda2fb

View File

@@ -981,38 +981,30 @@ function hasJob(job, source, grade) local hasJob = false
elseif GetResourceState(QBXExport):find("start") then elseif GetResourceState(QBXExport):find("start") then
local jobinfo = exports[QBXExport]:GetPlayer(src).PlayerData.job local jobinfo = exports[QBXExport]:GetPlayer(src).PlayerData.job
if jobinfo.name == job then if jobinfo.name == job then hasJob = true
hasJob = true
if grade and not (grade <= jobinfo.grade.level) then hasJob = false end if grade and not (grade <= jobinfo.grade.level) then hasJob = false end
end end
local ganginfo = exports[QBXExport]:GetPlayer(src).PlayerData.gang local ganginfo = exports[QBXExport]:GetPlayer(src).PlayerData.gang
if ganginfo.name == job then if ganginfo.name == job then 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
elseif GetResourceState(QBExport):find("start") and not GetResourceState(QBXExport):find("start") then elseif GetResourceState(QBExport):find("start") and not GetResourceState(QBXExport):find("start") then
if Core.Functions.GetPlayer ~= nil then -- support older qb-core if Core.Functions.GetPlayer then -- support older qb-core functions
local Player = Core.Functions.GetPlayer(src).PlayerData
local jobinfo = Player.job
if jobinfo.name == job then
hasJob = true
if grade and not (grade <= jobinfo.grade.level) then hasJob = false end
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 local jobinfo = Core.Functions.GetPlayer(src).PlayerData.job
if jobinfo.name == job then if jobinfo.name == job then hasJob = true
hasJob = true
if grade and not (grade <= jobinfo.grade.level) then hasJob = false end if grade and not (grade <= jobinfo.grade.level) then hasJob = false end
end end
local ganginfo = Core.Functions.GetPlayer(src).PlayerData.gang local ganginfo = Core.Functions.GetPlayer(src).PlayerData.gang
if ganginfo.name == job then if ganginfo.name == job then hasJob = true
hasJob = true if grade and not (grade <= ganginfo.grade.level) then hasJob = false end
end
else -- support newer qb-core exports
local jobinfo = exports[QBExport]: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 = exports[QBExport]:GetPlayer(src).PlayerData.gang
if ganginfo.name == job then 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
end end
@@ -1041,7 +1033,7 @@ function hasJob(job, source, grade) local hasJob = false
if ganginfo.name == job then hasJob = true if ganginfo.name == job then 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(QBXExport):find("start") and not GetResourceState(QBXExport):find("start") then
local info = nil local info = nil
Core.Functions.GetPlayerData(function(PlayerData) Core.Functions.GetPlayerData(function(PlayerData)
info = PlayerData info = PlayerData
@@ -1061,9 +1053,10 @@ function hasJob(job, source, grade) local hasJob = false
return hasJob return hasJob
end end
function getPlayer(src) local Player = {} function getPlayer(source) local Player = {}
if Config.System.Debug then print("^6Bridge^7: ^2Getting ^3Player^2 info^7") end if Config.System.Debug then print("^6Bridge^7: ^2Getting ^3Player^2 info^7") end
if src then -- If called from server if source then -- If called from server
local src = tonumber(source)
if GetResourceState(ESXExport):find("start") then if GetResourceState(ESXExport):find("start") then
local info = ESX.GetPlayerFromId(src) local info = ESX.GetPlayerFromId(src)
Player = { Player = {
@@ -1090,7 +1083,7 @@ function getPlayer(src) local Player = {}
bank = info.Functions.GetMoney("bank"), bank = info.Functions.GetMoney("bank"),
} }
elseif GetResourceState(QBExport):find("start") and not GetResourceState(QBXExport):find("start") then elseif GetResourceState(QBExport):find("start") and not GetResourceState(QBXExport):find("start") then
local info = Core.Functions.GetPlayer(tonumber(src)) local info = exports[QBExport]:GetPlayer(src)
Player = { Player = {
name = info.PlayerData.charinfo.firstname.." "..info.PlayerData.charinfo.lastname, name = info.PlayerData.charinfo.firstname.." "..info.PlayerData.charinfo.lastname,
cash = info.PlayerData.money["cash"], cash = info.PlayerData.money["cash"],
@@ -1098,7 +1091,7 @@ function getPlayer(src) local Player = {}
} }
end end
else else
if ESX ~= nil then if GetResourceState(ESXExport):find("start") and ESX ~= nil then
local info = ESX.GetPlayerData() local info = ESX.GetPlayerData()
local cash, bank = 0, 0 local cash, bank = 0, 0
for k, v in pairs(ESX.GetPlayerData().accounts) do for k, v in pairs(ESX.GetPlayerData().accounts) do
@@ -1124,11 +1117,9 @@ function getPlayer(src) local Player = {}
cash = info.money["cash"], cash = info.money["cash"],
bank = info.money["bank"], bank = info.money["bank"],
} }
else elseif GetResourceState(QBExport):find("start") and not GetResourceState(QBXExport):find("start") then
local info = nil local info = nil
Core.Functions.GetPlayerData(function(PlayerData) Core.Functions.GetPlayerData(function(PlayerData) info = PlayerData end)
info = PlayerData
end)
Player = { Player = {
name = info.charinfo.firstname.." "..info.charinfo.lastname, name = info.charinfo.firstname.." "..info.charinfo.lastname,
cash = info.money["cash"], cash = info.money["cash"],