Skip to content

OnPlayerText

A plain chat line - return false and nobody sees it.

Never a / command (those are OnPlayerCommandText). Anything but false lets the line through to everyone connected, in the player’s own colour. Filters, team channels, a muted player, a whisper: return false and send the line on yourself with SendClientMessage.

function OnPlayerText(pid, text)
-- ...
end
Parameter Type
pid number who typed it
text string the line, as typed

false suppresses the line; anything else (or nothing) lets it through

-- team chat: a line starting with "!" goes to the team alone
function OnPlayerText(pid, text)
local team = GetPlayerTeam(pid)
if text:sub(1, 1) == "!" and team ~= NO_TEAM then
for _, other in ipairs(GetPlayers()) do
if GetPlayerTeam(other) == team then
SendClientMessage(other, GetPlayerColour(pid), "[team] " .. GetPlayerName(pid) .. ": " .. text:sub(2))
end
end
return false
end
return true
end

OnPlayerCommandText · SendClientMessage · SendClientMessageToAll · the Chat and commands group of the index