mirror of
https://github.com/jimathy/jim_bridge.git
synced 2026-08-17 05:56:02 +01:00
getPlayer() fallback if player hasn't loaded yet
This commit is contained in:
@@ -539,6 +539,7 @@ function getPlayer(source)
|
|||||||
local src = tonumber(source)
|
local src = tonumber(source)
|
||||||
if isStarted(ESXExport) then
|
if isStarted(ESXExport) then
|
||||||
local info = ESX.GetPlayerFromId(src)
|
local info = ESX.GetPlayerFromId(src)
|
||||||
|
if not info then return {} end
|
||||||
Player = {
|
Player = {
|
||||||
name = info.getName(),
|
name = info.getName(),
|
||||||
cash = info.getMoney(),
|
cash = info.getMoney(),
|
||||||
@@ -563,9 +564,10 @@ function getPlayer(source)
|
|||||||
local chunk = assert(load(import, ('@@ox_core/%s'):format(file)))
|
local chunk = assert(load(import, ('@@ox_core/%s'):format(file)))
|
||||||
chunk()
|
chunk()
|
||||||
local player = Ox.GetPlayer(src)
|
local player = Ox.GetPlayer(src)
|
||||||
|
if not player then return {} end
|
||||||
Player = {
|
Player = {
|
||||||
firstname = player.firstName,
|
firstname = player.firstName,
|
||||||
lastname = player.lastName ,
|
lastname = player.lastName,
|
||||||
name = ('%s %s'):format(player.firstName, player.lastName),
|
name = ('%s %s'):format(player.firstName, player.lastName),
|
||||||
cash = exports[OXInv]:Search(src, 'count', "money"),
|
cash = exports[OXInv]:Search(src, 'count', "money"),
|
||||||
bank = 0,
|
bank = 0,
|
||||||
@@ -581,6 +583,7 @@ function getPlayer(source)
|
|||||||
}
|
}
|
||||||
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
|
||||||
Player = {
|
Player = {
|
||||||
firstname = info.PlayerData.charinfo.firstname,
|
firstname = info.PlayerData.charinfo.firstname,
|
||||||
lastname = info.PlayerData.charinfo.lastname,
|
lastname = info.PlayerData.charinfo.lastname,
|
||||||
@@ -602,8 +605,9 @@ function getPlayer(source)
|
|||||||
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 then
|
if Core.Functions.GetPlayer(src) then
|
||||||
local info = Core.Functions.GetPlayer(src).PlayerData
|
local info = Core.Functions.GetPlayer(src).PlayerData
|
||||||
|
if not info then return {} end
|
||||||
Player = {
|
Player = {
|
||||||
firstname = info.charinfo.firstname,
|
firstname = info.charinfo.firstname,
|
||||||
lastname = info.charinfo.lastname,
|
lastname = info.charinfo.lastname,
|
||||||
@@ -626,8 +630,9 @@ function getPlayer(source)
|
|||||||
}
|
}
|
||||||
end
|
end
|
||||||
elseif isStarted(RSGExport) then
|
elseif isStarted(RSGExport) then
|
||||||
if Core.Functions.GetPlayer then
|
if Core.Functions.GetPlayer(src) then
|
||||||
local info = Core.Functions.GetPlayer(src).PlayerData
|
local info = Core.Functions.GetPlayer(src).PlayerData
|
||||||
|
if not info then return {} end
|
||||||
Player = {
|
Player = {
|
||||||
firstname = info.charinfo.firstname,
|
firstname = info.charinfo.firstname,
|
||||||
lastname = info.charinfo.lastname,
|
lastname = info.charinfo.lastname,
|
||||||
|
|||||||
Reference in New Issue
Block a user