Player id!


Hello guys, can someone help me? I am trying to make player id to show up in the chat window, but it doesn’t work…i’m not so good at scripting, i start doing it 2 days ago, sorry for my English…
[Edit] I add this to chat client, now it shows the player id in cat windows when I’m sending messages, but the thing is, If i disconnect from server and reconnect again instead of id 1 It will give me id 2, 3 or 4, depends how many time i reconnect. Does someone know what i have to do to show only 1 single id everytime when i connect or reconnect ?

RegisterNUICallback(‘chatResult’, function(data, cb)
chatInputActive = false

if not data.canceled then
local id = PlayerId()
local serverID = GetPlayerServerId(PlayerId())

local r, g, b = 0, 0x99, 255

if data.message:sub(1, 1) == '/' then
  TriggerServerEvent('_chat:messageEntered', '['..serverID..'] '.. GetPlayerName(id), { r, g, b }, data.message)




Why don’t you show people the code you already wrote


Oh, yes, sorry. That’s the part with the id: AddEventHandler(‘chat:addTemplate’, function(id, html)
template = {
id = id,
html = html


And you want this to be all the time?


Maybe you could try this on a server script?

AddEventHandler("chatMessage", function(source, color, message)
	if #message[1] ~= "/" then
		TriggerClientEvent("chatMessage", -1, tostring("^1[ "..source.." ] " .. GetPlayerName(source)))

I don’t mess with the chat events at all… So I am just kinda guessing.


I will try it now, thank you!
Edit: I tried, it doesn’t work, i will keep looking on forums.


Did it give you an error at all?


No, console is clean, no errors in it!



RegisterCommand('showid', function(source)


He wants it to be in their messages.


Oh. :man_facepalming:as in when a user just sends a message?


I believe so yes.


Is when players talk in chat to see their id…


thanks for help, but it’s still doesn’t work…


you need to create a new chat template, cant help you with that as ive never done it but should be easy to research :smiley: