From 54261ecb4e59270ba3b6f8e5716970bfe9eacab9 Mon Sep 17 00:00:00 2001 From: Cocodrulo <142546774+Cocodrulo@users.noreply.github.com> Date: Wed, 8 Jan 2025 13:25:04 +0100 Subject: [PATCH 1/4] Add function to retrieve player's full name from character info --- client/functions.lua | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/client/functions.lua b/client/functions.lua index 45034a573..b329f24b5 100644 --- a/client/functions.lua +++ b/client/functions.lua @@ -36,6 +36,11 @@ function QBCore.Functions.HasItem(items, amount) return exports['qb-inventory']:HasItem(items, amount) end +function exports.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 From e288b742c87f3403c7bdeb3aaa60a3a88d9b2d2a Mon Sep 17 00:00:00 2001 From: Cocodrulo <142546774+Cocodrulo@users.noreply.github.com> Date: Wed, 8 Jan 2025 13:25:07 +0100 Subject: [PATCH 2/4] Add function to retrieve player's full name from character data --- server/player.lua | 5 +++++ 1 file changed, 5 insertions(+) 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) From f553fe3f260168b47435676b12f344bd9ee47c08 Mon Sep 17 00:00:00 2001 From: Cocodrulo <142546774+Cocodrulo@users.noreply.github.com> Date: Wed, 8 Jan 2025 13:27:48 +0100 Subject: [PATCH 3/4] Add function to retrieve full character name --- client/functions.lua | 2 ++ 1 file changed, 2 insertions(+) diff --git a/client/functions.lua b/client/functions.lua index b329f24b5..e99ece540 100644 --- a/client/functions.lua +++ b/client/functions.lua @@ -36,6 +36,8 @@ function QBCore.Functions.HasItem(items, amount) return exports['qb-inventory']:HasItem(items, amount) end +---Returns the full character name +---@return string function exports.Functions.GetName() local charinfo = QBCore.PlayerData.charinfo return charinfo.firstname .. ' ' .. charinfo.lastname From c3ad04d0c9d3104ce1ebb7d774fa695dc6a20b31 Mon Sep 17 00:00:00 2001 From: Cocodrulo <142546774+Cocodrulo@users.noreply.github.com> Date: Wed, 8 Jan 2025 13:31:03 +0100 Subject: [PATCH 4/4] fix: Refactor GetName function to use QBCore namespace --- client/functions.lua | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/client/functions.lua b/client/functions.lua index e99ece540..5ea6151b0 100644 --- a/client/functions.lua +++ b/client/functions.lua @@ -38,7 +38,7 @@ end ---Returns the full character name ---@return string -function exports.Functions.GetName() +function QBCore.Functions.GetName() local charinfo = QBCore.PlayerData.charinfo return charinfo.firstname .. ' ' .. charinfo.lastname end