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.
Syntax
Section titled “Syntax”function OnPlayerText(pid, text) -- ...end| Parameter | Type | |
|---|---|---|
pid |
number | who typed it |
text |
string | the line, as typed |
Returns
Section titled “Returns”false suppresses the line; anything else (or nothing) lets it through
Example
Section titled “Example”-- team chat: a line starting with "!" goes to the team alonefunction 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 trueendSee also
Section titled “See also”OnPlayerCommandText · SendClientMessage · SendClientMessageToAll · the Chat and commands group of the index
