Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Feat: Added Player.Functions.GetName() function and QBCore.Functions.GetName() #1161

Merged
merged 5 commits into from
Jan 10, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Loading