Color for ply:ChatPrint

How do i make things colored with ply:ChatPrint?

Why use chat print instead of umsg?

You don’t, you need to send a net message and use chat.AddText clientside.
Example:

[lua]
– lua/autorun/sh_coloredmessages.lua

if (SERVER) then
AddCSLuaFile();

 util.AddNetworkString("ColoredChatMessage");
 local ply = FindMetaTable("Player");

 function ply:ColoredChatPrint(...)
      local args = {...};
 
      net.Start("ColoredChatMessage");
      net.WriteTable(filtered);
      net.Send(self);
 end;

else
net.Receive(“ColoredChatMessage”, function(len)
local args = net.ReadTable();
chat.AddText(args);
end);
end;
[/lua]

[lua]
– usage example - must be serverside code
player:ColoredChatPrint(Color(0, 255, 0), "You equipped the “, Color(0, 0, 255), “Item With Name In Blue”, Color(0, 255, 0), " and are therefore awesome.”);
[/lua]
Result:

Didn’t test this, but it should work.
There is some limit on how much text you can send with this code but you shouldn’t really get even close to it during normal usage.
Use ply:ColoredChatPrint on the server exactly like the chat.AddText function.

Usermessages are deprecated. Use the net library.
They are still in the code for the sake of backwards compatibility but I’m sure they will use the net library behind the scenes once the next update comes out.

well what i was using it for is a pointshop item and when you buy it, it will put in color you got this item.

-Didn’t realize you needed it clientside-

Ok how would i do the server side part? Because i thought that the items are ran through client.

If you want to add a colored message to the client the code is running on, it’s just simple as that:
[lua]
chat.AddText(Color(R, G, B), “Message”)
[/lua]

where R, G and B are numbers from 0-255, you can put more colors in. See my previous post for a link to chat.AddText documentation.

Ok thank you for the help