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