I’m trying to toggle user’s first name and last name in chat when toggle id button is pressed but nothing happens when I do that. I’ve tried a lot but no luck.
Here’s my client.lua
function getIdentity(source, callback)
local identifier = GetPlayerIdentifiers(source)[1]
MySQL.Async.fetchAll("SELECT * FROM `users` WHERE `identifier` = @identifier",
{
['@identifier'] = identifier
},
function(result)
if result[1]['firstname'] ~= nil then
local data = {
identifier = result[1]['identifier'],
firstname = result[1]['firstname'],
lastname = result[1]['lastname']
}
callback(data)
end
end)
end
RegisterNUICallback('toggleid', function(data)
TriggerEvent('menu:id', data)
end)
.....
RegisterNetEvent('menu:id')
AddEventHandler('menu:id', function()
getIdentity(source, function(data)
TriggerClientEvent('chatMessage', -1, '', {217, 217, 217}, "" .. data.firstname .. " " .. data.lastname)
end)
end)