TalkToPerson

Alright I need help.
You see this?


TalkToPerson(v, col, LANGUAGE.advert .." "..ply:Nick().. " (ADMIN) ", col2, text, ply)

I want the word (ADMIN) to be color of “Color(20, 150, 20, 255)”.
I cant figure it out for the life of meh.

we’d have to see what TalkToPerson is.

Its from DarkRP. Basically prints to chat.
col
and
col2
are variable colors btw.

This is just a wild guess
[lua]
TalkToPerson(v, col, LANGUAGE.advert …" "…ply:Nick(),Color(20, 150, 20, 255), " (ADMIN) ", col2, text, ply)
[/lua]
Assuming it uses **[Chat.AddText

http://wiki.garrysmod.com/favicon.ico](http://wiki.garrysmod.com/?title=Chat.AddText)**

It makes the word admin green, but it wont print the text.

Then post the function source for us or we can’t help you.

Im currently editing DarkRP, and this is my second day scripting. I do not know were to find the function.

Open every file and make a search for



function TalkToPerson


Yea. I just noticed that.
Here you go :slight_smile:



function TalkToPerson(receiver, col1, text1, col2, text2, sender)
	umsg.Start("DarkRP_Chat", receiver)
		umsg.Short(col1.r)
		umsg.Short(col1.g)
		umsg.Short(col1.b)
		umsg.String(text1)
		if sender then
			umsg.Entity(sender)
		end
		if col2 and text2 then
			umsg.Short(col2.r)
			umsg.Short(col2.g)
			umsg.Short(col2.b)
			umsg.String(text2)
		end
	umsg.End()
end


Thanks for your help :smiley:

Aight, now do a search for



üsermessage.Hook("DarkRP_Chat"


In the client files and post the source of the function that is hooked.



local function AddToChat(msg)
	local col1 = Color(msg:ReadShort(), msg:ReadShort(), msg:ReadShort())

	local name = msg:ReadString()
	local ply = msg:ReadEntity()
	local col2 = Color(msg:ReadShort(), msg:ReadShort(), msg:ReadShort())

	local text = msg:ReadString()
	if text and text ~= "" then
		chat.AddText(col1, name, col2, ": "..text)
		if ValidEntity(ply) then
			hook.Call("OnPlayerChat", GM, ply, text, false, ply:Alive())
		end
	else
		chat.AddText(col1, name)
		hook.Call("ChatText", GM, "0", name, name, "none")
	end
	chat.PlaySound()
end
usermessage.Hook("DarkRP_Chat", AddToChat)


server-side
[lua]
function TalkToPersonAdmin(receiver, col1, text1, col2, text2, sender)
umsg.Start(“DarkRP_Chat_ADMIN”, receiver)
umsg.Short(col1.r)
umsg.Short(col1.g)
umsg.Short(col1.b)
umsg.String(text1)
if sender then
umsg.Entity(sender)
end
if col2 and text2 then
umsg.Short(col2.r)
umsg.Short(col2.g)
umsg.Short(col2.b)
umsg.String(text2)
end
umsg.End()
end
[/lua]

client-side
[lua]
local function AddToChatADMIN(msg)
local col1 = Color(msg:ReadShort(), msg:ReadShort(), msg:ReadShort())

local name = msg:ReadString()
local ply = msg:ReadEntity()
local col2 = Color(msg:ReadShort(), msg:ReadShort(), msg:ReadShort())

local text = msg:ReadString()
if text and text ~= "" then
	chat.AddText(col1, name,Color(20, 150, 20, 255)," (ADMIN) ", col2, ": "..text)
	if ValidEntity(ply) then
		hook.Call("OnPlayerChat", GM, ply, text, false, ply:Alive())
	end
else
	chat.AddText(col1, name,Color(20, 150, 20, 255)," (ADMIN) ")
	hook.Call("ChatText", GM, "0", name, name, "none")
end
chat.PlaySound()

end
usermessage.Hook(“DarkRP_Chat_ADMIN”, AddToChatADMIN)
[/lua]

It works, thanks man. It saved me a shit-ton of time.