VRP Problems with firstname and name in /me

Hello, I want to add Firstname and name into /me command.
For example: “Jason Starve get a key”.
I tried to use “getUserIdentity” e.t.c.
Nothing really works. Can somone showe me how to do it properly?
(I’ve often had a error with: “attempt to index a nil value”)

me-server.lua (596 Bytes)

Try to look at the standard scoreboard from vRP. Or look at his documentation :slight_smile:

1 Like
function getIdentity(source)
	local user_idd = vRP.getUserId({source})
    local result = MySQL.Sync.fetchAll("SELECT firstname, name, age, phone, registration FROM vrp_user_identities WHERE user_id = @user_id", {
			['@user_id'] = user_idd
    })
  if result[1] ~= nil then
    local user = result[1]
  
  return {
    firstname = user['firstname'],
    lastname = user['name'],
    age = user['age'],
    phone = user['phone'],
    height = user['registration'],
  }
  else
    return nil
    end
end


AddEventHandler('chatMessage', function(source, name, msg)
		local user_idd = vRP.getUserId({source})
		sm = stringsplit(msg, " ");
			if sm[1] == "/me" then
				CancelEvent()
				TriggerClientEvent('chatMessage', -1, "^6 " ..getIdentity(source).firstname.. " ".. getIdentity(source).lastname ..  '^6' .. string.sub(msg,4))
			end
end)

:relaxed:

1 Like

Yeah you got it. Well done :slight_smile: