chat:addMessage sent to everyone

Hey guys,

Kinda looking for some help on how to send a client event (chat:addMessage) to every client in the server. I’ve tried several ways but none of them seem to work.

Here is my code:

RegisterCommand("rcon_announce", function(source, args, rawCommand)
	if source == 0 or source == "console" then
		local message = rawCommand:gsub('rcon_announce ', '')
        TriggerEvent('chat:addMessage', {
            color = { 255, 153, 51},
            template = '<div style="padding: 0.5vw; margin: 0.5vw; background-color: rgba(41, 41, 41, 0.6);">{0} {1}</div>',
            args = {"^8[Console Announcement] ", "^7" .. message}
        })
	end
end)

Put that code in a server script change the event triggered to

TriggerClientEvent('chat:addMessage', -1, {
            color = { 255, 153, 51},
            template = '<div style="padding: 0.5vw; margin: 0.5vw; background-color: rgba(41, 41, 41, 0.6);">{0} {1}</div>',
            args = {"^8[Console Announcement] ", "^7" .. message}
        })
1 Like

Thanks so much, this worked!

1 Like