diff --git a/client/functions.lua b/client/functions.lua index 8c03183e0..737b12c0c 100644 --- a/client/functions.lua +++ b/client/functions.lua @@ -48,6 +48,13 @@ function QBCore.Functions.HasItem(items, amount) return exports['qb-inventory']:HasItem(items, amount) end +---Returns the full character name +---@return string +function QBCore.Functions.GetName() + local charinfo = QBCore.PlayerData.charinfo + return charinfo.firstname .. ' ' .. charinfo.lastname +end + ---@param entity number - The entity to look at ---@param timeout number - The time in milliseconds before the function times out ---@param speed number - The speed at which the entity should turn diff --git a/server/player.lua b/server/player.lua index cbc503222..4f73c0d30 100644 --- a/server/player.lua +++ b/server/player.lua @@ -253,6 +253,11 @@ function QBCore.Player.CreatePlayer(PlayerData, Offline) return QBCore.Functions.HasItem(self.PlayerData.source, items, amount) end + function self.Functions.GetName() + local charinfo = self.PlayerData.charinfo + return charinfo.firstname .. ' ' .. charinfo.lastname + end + function self.Functions.SetJobDuty(onDuty) self.PlayerData.job.onduty = not not onDuty TriggerEvent('QBCore:Server:OnJobUpdate', self.PlayerData.source, self.PlayerData.job)