Player id in chat + job title and color

How do i add palyer id and this chat design ? dasdasdsavvv pls help me

That’s a custom chat design.

1 Like

@bormasina_ion
Look here:

RegisterCommand('chatmessage', function(source, args, rawCommand)
	rawCommand = string.sub(rawCommand, 12)
	local name = GetPlayerName(source)
	local playerNick = GetPlayerName(source)
	TriggerClientEvent('chat:addMessage', -1, { args = { '['..source..'] '..name, rawCommand }, color = { 56, 71, 94 } })


end, false)

Its simple. If you want to add job just use xPlayer.

(‘source’ is ID)

1 Like

You’re registering a command called ‘chatmessage’…

Just to show him how to use it.

can u post yours ?

How can I do other chat color for superadmin, admin and moderator?

My nick ? Why ? lol

You can use RolesFX for this.

-- Made by Tazio
ESX = nil
TriggerEvent('esx:getSharedObject', function(obj) ESX = obj end)


AddEventHandler('chatMessage', function(source, name, msg)
local name = GetPlayerName(source)
   local playerNick = GetPlayerName(source)
	sm = stringsplit(msg, " ");
       if string.find(sm[1], "/") then
	else 
        if sm[1]  then
        
		CancelEvent()
    xPlayer = ESX.GetPlayerFromId(source)
    str = xPlayer.job.name
    job = str:gsub("^%l", string.upper)
  
    TriggerClientEvent('chatMessage', -1, "^7[ ^4".. job .. " ^7]^7   ^3" .. name .. "^2(".. source ..")^2 ", { 255, 0, 0 }, string.sub(msg,0))
	end
 end
end)

function stringsplit(inputstr, sep)
    if sep == nil then
        sep = "%s"
    end
    local t={} ; i=1
    for str in string.gmatch(inputstr, "([^"..sep.."]+)") do
        t[i] = str
        i = i + 1
    end
    return t
end

2 Likes

Could you give me an example how to add it to ooc? thank you