Better workarounds for no info yet to getPlayer()

This commit is contained in:
Jim Shield
2025-05-26 19:10:54 +01:00
parent c86cdf9227
commit 3daa6a9772

View File

@@ -579,8 +579,8 @@ function getPlayer(source)
--onDuty = info.job.onduty,
--account = info.charinfo.account,
citizenId = player.stateId,
}
elseif isStarted(QBXExport) then
local info = exports[QBXExport]:GetPlayer(src)
if not info then return {} end
@@ -604,6 +604,7 @@ function getPlayer(source)
isDown = info.PlayerData.metadata["inlaststand"],
charInfo = info.charinfo,
}
elseif isStarted(QBExport) and not isStarted(QBXExport) then
if Core.Functions.GetPlayer(src) then
local info = Core.Functions.GetPlayer(src).PlayerData
@@ -629,6 +630,7 @@ function getPlayer(source)
charInfo = info.charinfo,
}
end
elseif isStarted(RSGExport) then
if Core.Functions.GetPlayer(src) then
local info = Core.Functions.GetPlayer(src).PlayerData
@@ -653,6 +655,7 @@ function getPlayer(source)
isDown = info.metadata["inlaststand"],
charInfo = info.charinfo,
}
end
else
print("^4ERROR^7: ^2No Core detected for getPlayer() - Check starter.lua")
@@ -661,6 +664,8 @@ function getPlayer(source)
-- Client-side: Get current player info.
if isStarted(ESXExport) and ESX ~= nil then
local info = ESX.GetPlayerData()
if not info.firstName then return {} end
local cash, bank = 0, 0
for k, v in pairs(info.accounts) do
if v.name == "money" then cash = v.money end
@@ -683,7 +688,9 @@ function getPlayer(source)
isDead = IsEntityDead(PlayerPedId()),
isDown = IsPedDeadOrDying(PlayerPedId(), true)
}
elseif isStarted(OXCoreExport) then
if not OxPlayer.userId then return {} end
Player = {
firstname = OxPlayer.get("firstName"),
lastname = OxPlayer.get("lastName"),
@@ -701,8 +708,10 @@ function getPlayer(source)
isDead = IsEntityDead(PlayerPedId()),
isDown = IsPedDeadOrDying(PlayerPedId(), true)
}
elseif isStarted(QBXExport) then
local info = exports[QBXExport]:GetPlayerData()
if not info.charinfo then return {} end
Player = {
firstname = info.charinfo.firstname,
lastname = info.charinfo.lastname,
@@ -723,9 +732,12 @@ function getPlayer(source)
isDown = info.metadata["inlaststand"],
charInfo = info.charinfo,
}
elseif isStarted(QBExport) and not isStarted(QBXExport) then
local info = nil
Core.Functions.GetPlayerData(function(PlayerData) info = PlayerData end)
if not info.charinfo then return {} end
Player = {
firstname = info.charinfo.firstname,
lastname = info.charinfo.lastname,
@@ -746,9 +758,12 @@ function getPlayer(source)
isDown = info.metadata["inlaststand"],
charInfo = info.charinfo,
}
elseif isStarted(RSGExport) then
local info = nil
Core.Functions.GetPlayerData(function(PlayerData) info = PlayerData end)
if not info.charinfo then return {} end
Player = {
firstname = info.charinfo.firstname,
lastname = info.charinfo.lastname,
@@ -769,6 +784,7 @@ function getPlayer(source)
isDown = info.metadata["inlaststand"],
charInfo = info.charinfo,
}
else
print("^4ERROR^7: ^2No Core detected for hasJob ^7- ^2Check ^3starter^1.^2lua^7")
end