Skip to content

Commit

Permalink
Merge pull request #1161 from Cocodrulo/feature/getname
Browse files Browse the repository at this point in the history
Feat: Added Player.Functions.GetName() function and QBCore.Functions.GetName()
  • Loading branch information
GhzGarage authored Jan 10, 2025
2 parents 8f9d482 + 6f6bcf0 commit 9898682
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 0 deletions.
7 changes: 7 additions & 0 deletions client/functions.lua
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
5 changes: 5 additions & 0 deletions server/player.lua
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down

0 comments on commit 9898682

Please sign in to comment.