How to change from steam name to roleplay name?

hello,so in my police job script is some kind of notification for duty,but when i use it it says steam name and i wana make it say roleplay names i cant figure it out,if you know i i would be very grateful if you can help meOn pictures you can see curent script slika_2020-11-05_230139 unknown

RegisterServerEvent(‘police:PriseEtFinservice’)

AddEventHandler(‘police:PriseEtFinservice’, function(PriseOuFin)

local _source = source

local _raison = PriseOuFin

local xPlayer = ESX.GetPlayerFromId(_source)

local xPlayers = ESX.GetPlayers()

local name = xPlayer.getName(_source)

for i = 1, #xPlayers, 1 do

    local thePlayer = ESX.GetPlayerFromId(xPlayers[i])

    if thePlayer.job.name == 'police' then

        TriggerClientEvent('police:InfoService', xPlayers[i], _raison, name)

    end

end

end)

1 Like

Try this:
GetCharacterName(_source)
Instead of:

xPlayer.getName(_source)

I changed it to GetCharacherName(_source)- this is eror i gotunknown

sorry, xd
I forgot to add the function

function GetCharacterName(_source)
	local result = MySQL.Sync.fetchAll('SELECT firstname, lastname FROM users WHERE identifier = @identifier', {
		['@identifier'] = GetPlayerIdentifiers(source)[1]
	})

	if result[1] and result[1].firstname and result[1].lastname then
			return ('%s %s'):format(result[1].firstname, result[1].lastname)
	else
		return GetPlayerName(_source)
	end
end
1 Like

it works thank you so much :heart:

1 Like

This topic was automatically closed 30 days after the last reply. New replies are no longer allowed.