It´s me again.
How can I do a Chat Message with a different Color and with a Username ? That´s what I mean:
If The Traitor do a [B]Primary Attack[/B], Everybody on the Server shall get a [B]ChatMessage (In another Color than White) like that:[/B] [I]"TRAITOR-ITEM-NAME: "Username of the Traitor" has used his Traitoritem"
[/I]
Can I do something like that with [B]PrintMessage[/B] or do I need the [B]net Library[/B] ?
Thanks for your help.
This should work.
[code]if (SERVER) then
util.AddNetworkString("SendColouredMessage");
local plyMeta = FindMetaTable("Player");
function plyMeta:SendMessage(colour, text)
text = text or "";
colour = colour or Color(60, 60, 255);
net.Start("SendColouredMessage");
net.WriteString(text);
net.WriteColor(colour);
net.Send(self);
end
local BroadcastChatMessage = function(colour, text)
for i, ply in ipairs(player.GetHumans()) do
ply:SendMessage(text, colour);
end
end
elseif (CLIENT) then
net.Receive("SendColouredMessage", function()
local text = net.ReadString();
local colour = net.ReadColor();
chat.AddText(colour, text);
end)
end
[/code]
[editline]16th January 2017[/editline]
Player:SendMessage to target 1 player at a time or you can use BroadcastChatMessage to target all players.
[QUOTE=thejjokerr;51679727]You will need: [url]http://wiki.garrysmod.com/page/chat/AddText[/url] in combination with a net message.[/QUOTE]
That´s my problem. I don´t know how.
Sorry, you need to Log In to post a reply to this thread.