2026-04-14 17:41:39 +02:00

45 lines
1.4 KiB
Lua

local ESX, QBCore
-- ESX (both legacy and new exports)
if GetResourceState('es_extended') == 'started' then
if exports['es_extended'].getSharedObject then
ESX = exports['es_extended']:getSharedObject()
else
TriggerEvent('esx:getSharedObject', function(obj) ESX = obj end)
end
end
-- QBCore
if GetResourceState('qb-core') == 'started' then
QBCore = exports['qb-core']:GetCoreObject()
end
local getplyname = GetPlayerName
-- This function is what will get used in the radio overlay
function getOverlayName(source)
if ESX then
local xPlayer = ESX.GetPlayerFromId(source)
if xPlayer then
local fn = xPlayer.get('firstName') or xPlayer.get('firstname') or xPlayer.get('first_name')
local ln = xPlayer.get('lastName') or xPlayer.get('lastname') or xPlayer.get('last_name')
if fn and ln then
return fn .. ' ' .. ln
end
end
end
if QBCore then
local qbPlayer = QBCore.Functions.GetPlayer(source)
if qbPlayer and qbPlayer.PlayerData and qbPlayer.PlayerData.charinfo then
local char = qbPlayer.PlayerData.charinfo
if char.firstname and char.lastname then
return char.firstname .. ' ' .. char.lastname
end
end
end
return getplyname(source)
end