Skip to content

Commit

Permalink
Merge branch 'main' into main
Browse files Browse the repository at this point in the history
  • Loading branch information
GhzGarage authored Sep 23, 2023
2 parents 79f83c2 + 1684fcd commit 4a09935
Show file tree
Hide file tree
Showing 2 changed files with 29 additions and 1 deletion.
7 changes: 7 additions & 0 deletions server/functions.lua
Original file line number Diff line number Diff line change
Expand Up @@ -76,6 +76,13 @@ function QBCore.Functions.GetOfflinePlayerByCitizenId(citizenid)
return QBCore.Player.GetOfflinePlayer(citizenid)
end

---Get player by license
---@param license string
---@return table?
function QBCore.Functions.GetPlayerByLicense(license)
return QBCore.Player.GetPlayerByLicense(license)
end

---Get player by phone number
---@param number number
---@return table?
Expand Down
23 changes: 22 additions & 1 deletion server/player.lua
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,28 @@ end

function QBCore.Player.GetOfflinePlayer(citizenid)
if citizenid then
local PlayerData = MySQL.Sync.prepare('SELECT * FROM players where citizenid = ?', {citizenid})
local PlayerData = MySQL.prepare.await('SELECT * FROM players where citizenid = ?', {citizenid})
if PlayerData then
PlayerData.money = json.decode(PlayerData.money)
PlayerData.job = json.decode(PlayerData.job)
PlayerData.position = json.decode(PlayerData.position)
PlayerData.metadata = json.decode(PlayerData.metadata)
PlayerData.charinfo = json.decode(PlayerData.charinfo)
if PlayerData.gang then
PlayerData.gang = json.decode(PlayerData.gang)
else
PlayerData.gang = {}
end

return QBCore.Player.CheckPlayerData(nil, PlayerData)
end
end
return nil
end

function QBCore.Player.GetPlayerByLicense(license)
if license then
local PlayerData = MySQL.prepare.await('SELECT * FROM players where license = ?', {license})
if PlayerData then
PlayerData.money = json.decode(PlayerData.money)
PlayerData.job = json.decode(PlayerData.job)
Expand Down

0 comments on commit 4a09935

Please sign in to comment.