Garry's Mod Wiki

Revision Difference

chat.AddText#514054

<function name="AddText" parent="chat" type="libraryfunc">⤶ <description>Adds text to the local player's chat box (which only they can read).</description>⤶ <realm>Client</realm>⤶ <args>⤶ <arg name="arguments" type="vararg">The arguments. Arguments can be:&#xA;* &lt;page&gt;table&lt;/page&gt; - &lt;page&gt;Color&lt;/page&gt;. Will set the color for all following strings until the next Color argument.&#xA;* &lt;page&gt;string&lt;/page&gt; - Text to be added to the chat box.&#xA;* &lt;page&gt;Player&lt;/page&gt; - Adds the name of the player in the player&#x27;s team color to the chat box.&#xA;* &lt;page&gt;any&lt;/page&gt; - Any other type, such as &lt;page&gt;Entity&lt;/page&gt; will be converted to string and added as text.</arg>⤶ </args>⤶ </function>⤶ ⤶ <example>⤶ <description>Prints the player's name and current weapon to their chat area.</description>⤶ <code>⤶ local ply = LocalPlayer()⤶ chat.AddText( Color( 100, 100, 255 ), ply, ", you are holding ", Color( 100, 255, 100 ), ply:GetActiveWeapon():GetClass() )⤶ </code>⤶ <output></output>⤶ ⤶ </example>