diff --git a/modules/framework/es_extended/server.lua b/modules/framework/es_extended/server.lua index 4d37030..41b37b8 100644 --- a/modules/framework/es_extended/server.lua +++ b/modules/framework/es_extended/server.lua @@ -78,6 +78,25 @@ Framework.GetPlayer = function(src) return xPlayer end +---@description Returns the player data of the specified identifier in the framework defualt format. +---@param citizenid string +---@return table | nil +Framework.GetPlayerByIdentifier = function(citizenid) + local player = ESX.GetPlayerFromIdentifier(citizenid) + if not player then return end + return player +end + +---@description This will return the player source of the specified citizen ID. +---@param citizenid string +---@return number | nil +Framework.GetPlayerSource = function(citizenid) + local player = Framework.GetPlayerByIdentifier(citizenid) + if not player then return end + return player.source +end + + --- @description Returns the citizen ID of the player. --- @param src number --- @return string | nil returns the citizen ID of the player if it exists diff --git a/modules/framework/qb-core/server.lua b/modules/framework/qb-core/server.lua index 3b9c92a..d244b0b 100644 --- a/modules/framework/qb-core/server.lua +++ b/modules/framework/qb-core/server.lua @@ -51,6 +51,25 @@ Framework.GetPlayer = function(src) return player end + +---@description Returns the player data of the specified identifier in the framework defualt format. +---@param citizenid string +---@return table | nil +Framework.GetPlayerByIdentifier = function(citizenid) + local player = QBCore.Functions.GetPlayerByCitizenId(citizenid) + if not player then return end + return player +end + +---@description This will return the player source of the specified citizen ID. +---@param citizenid string +---@return number | nil +Framework.GetPlayerSource = function(citizenid) + local player = Framework.GetPlayerByIdentifier(citizenid) + if not player then return end + return player.PlayerData.source +end + ---@description This will return the jobs registered in the framework in a table. ---@return table {name = jobName, label = jobLabel, grade = {name = gradeName, level = gradeLevel}} Framework.GetFrameworkJobs = function() diff --git a/modules/framework/qbx_core/server.lua b/modules/framework/qbx_core/server.lua index 98b086c..f8431aa 100644 --- a/modules/framework/qbx_core/server.lua +++ b/modules/framework/qbx_core/server.lua @@ -44,6 +44,25 @@ Framework.GetPlayer = function(src) return player end + +---@description Returns the player data of the specified identifier in the framework defualt format. +---@param citizenid string +---@return table | nil +Framework.GetPlayerByIdentifier = function(citizenid) + local player = QBox:GetPlayerByCitizenId(citizenid) + if not player then return end + return player +end + +---@description This will return the player source of the specified citizen ID. +---@param citizenid string +---@return number | nil +Framework.GetPlayerSource = function(citizenid) + local player = Framework.GetPlayerByIdentifier(citizenid) + if not player then return end + return player.PlayerData.source +end + ---@description Returns a table of the jobs in the framework. ---@return table Framework.GetFrameworkJobs = function()