ServersYour serverFor creatorsForumFAQDocumentationSecurity
Download the launcher
  1. Documentation
  2. Server events
  3. onPlayerChat

Event

onPlayerChat

ServerChat and consoleIdentical to MTA:SA

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.
messageTypeint
0 normal, 1 /me action.

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)

See also