- Documentation
- Server events
- onPlayerChat
Event
onPlayerChat
A player wrote a chat message (a normal one or /me). You can block it, e.g. to send your own formatted one.
Handler
addEventHandler("onPlayerChat", root, function(message, messageType) ... end)Parameters
messagestring- The message.
messageTypeint0normal,1/meaction.
Source
source is the player.
cancelEvent() blocks the message.
Example
Chat with the team colour before the nick.
addEventHandler("onPlayerChat", root, function(message, messageType)
if messageType ~= 0 then return end
cancelEvent()
local r, g, b = getPlayerNametagColor(source)
outputChatBox(getPlayerName(source) .. ": #FFFFFF" .. message, root, r, g, b, true)
end)