Garry's Mod Wiki

Revision Difference

GM:PlayerSay#517769

<function name="PlayerSay" parent="GM" type="hook"> <ishook>yes</ishook> <description>Called when a player dispatched a chat message. For the clientside equivalent, see <page>GM:OnPlayerChat</page>.</description> <realm>Server</realm> <predicted>No</predicted> <args> <arg name="sender" type="Player">The player which sent the message.</arg> <arg name="text" type="string">The message&#x27;s content</arg> <arg name="text" type="string">The message's content</arg> <arg name="teamChat" type="boolean">Is team chat?</arg> </args> <rets> <ret name="" type="string">What to show instead of original text. Set to "" to stop the message from displaying.</ret> </rets> </function> <example> <description>Will put "[Global]" in front of the players message if they type "/all " before the message.</description> <code> hook.Add("PlayerSay", "PlayerSayExample", function( ply, text, team ) -- Make the chat message entirely lowercase if ( string.sub(string.lower( text ),1,4) == "/all" ) then return "[Global] " .. string.sub( text, 5 ) -- add [Global] in front of the players text then display end end) </code> </example>