Message to all players not working


#1

Hi all, so I have this code and was wondering why it won’t display the message to all players online. I have tried many things and its probably something simple lol.

The aim of it is to display a message to all players when the command is entered.

Client.lua

RegisterNetEvent('testmsg')
AddEventHandler('testmsg', function()
	TriggerEvent('chatMessage', -1, "^8Test Message", string.sub(msg,5))
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

Server.lua

RegisterCommand ('testmsg')
	TriggerClientEvent('testmsg')
end)

#2

Ok I have it working, but is there a way to do line breaks in the chat message

I want it to appear like;

--------------------------------------------
MESSAGE (Msg)
--------------------------------------------

Heres the chat output line

TriggerEvent("chatMessage", "Sender Name", {239, 0, 0}, "text to send", "Sender Name 2", {239, 0, 0})

#3

You should be able to use a normal carrot \n from doc https://www.lua.org/pil/2.4.html

TriggerEvent("chatMessage", "Sender Name", {239, 0, 0}, "text to\n send", "Sender Name 2", {239, 0, 0})

#4

I have this working ages ago :smiley: as you see 9 months ago.


#5

LOL i found this post on a similar search so i know one days someone will need this solution lol.