local xPlayer = ESX.GetPlayerFromId(source)
MySQL.Async.fetchAll('SELECT firstname, lastname FROM users WHERE identifier = @identifier', {['@identifier'] = xPlayer.identifier},
function(data)
if (data[1] ~= nil) then
local firstName = data[1].firstname
local lastName = data[1].lastname
cb(firstName, lastName)
else
cb(false)
end
end)
i got this one in another script working but i got trouble to understand your part and edit it correctly, i have to admit it’s way over my knoweldge 
each time i tried to edit it i get error message saying commands dont exist but i’m not surprised since it seem to be a different layout (also a servercallback, not a function, dunno if it change something tbh)
function getIdentity(source, callback)
local xPlayer = ESX.GetPlayerFromId(source)
MySQL.Async.fetchAll('SELECT identifier, firstname, lastname, dateofbirth, sex, height FROM `users` WHERE `identifier` = @identifier', {
['@identifier'] = xPlayer.identifier
}, function(result)
if result[1].firstname ~= nil then
local data = {
identifier = result[1].identifier,
firstname = result[1].firstname,
lastname = result[1].lastname,
dateofbirth = result[1].dateofbirth,
sex = result[1].sex,
height = result[1].height
}
callback(data)
else
local data = {
identifier = '',
firstname = '',
lastname = '',
dateofbirth = '',
sex = '',
height = ''
}
callback(data)
end
end)
end
and this it the similar function directly in esx_identity i use, it’s looking a bit more similare maybe it’s a better way to go, i’ll keep trying to understand exactly how work your part

local ok, firstName, lastName = getESXPlayername()
this line especialy, it’s the first time i see something like that