help with hooking.

Alright so right now, i have a function that prints something to the players chat( thanks to feihc ).
So what im trying to change right now is to add color to the text, so i have to use the command chat.addtext.

Current realm this code is in shared, chat.addtext is client.
So taking a guess i need to hook it, right?
Need help with that though.

What orginally was the code:
[lua]
concommand.Add(“BroadcastKiller”, function(ply, cmd, args)
for k, v in pairs(player.GetAll()) do
if v:IsAdmin() then
v:ChatPrint( “RDM Report: " … ply:Nick() … " has reported that " … args[1]… " has randomly killed him, check it out.” )

    end		
end

end)
[/lua]

What I tried to do:
in the shared realm:
[lua]
concommand.Add(“BroadcastKiller”, function(ply, cmd, args)
umsg.Start(“NotifyKiller”, ply)
umsg.End()

end

end
[/lua]
and in the client realm
[lua]
function NotifyKiller()
for k, v in pairs(player.GetAll()) do
if v:IsAdmin() then
v:AddText(Color(255,0,0), “RDM Report: " … ply:Nick() … " has reported that " … args[1]… " has randomly killed him, check it out.” )

end

usermessage.Hook(“NotifyKiller”, NotifyKiller)
[/lua]

probably screwed up heavly, but bare with me cause im trying to learn:/

args[1] is nil on client

Is there any easy way to fix this then? or should i just stay with what i have.

also should of mentioned, no errors or anything it just breaks it.

send the args in a usermessage too

[editline]26th May 2011[/editline]

place in lua/autorun

[lua]
if (SERVER) then
concommand.Add(“SendKiller”, function(ply, cmd, args)
umsg.Start(“SendRDMReport”, ply)
umsg.String( args[1] )
umsg.End()
end)
end

if (CLIENT) then
local RecievedInfo = {}

usermessage.Hook("SendRDMReport", function( um )
	table.insert(RecievedInfo, um:ReadString())
end)

hook.Add("HUDPaint", "DrawKillers", function()
	for k, v in pairs( RecievedInfo ) do
		draw.SimpleTextOutlined(v, "TargetID", 20, 20 + (k * 20), Color(0, 0, 0), TEXT_ALIGN_LEFT, TEXT_ALIGN_LEFT, 1, Color(0, 255, 0))
	end
end)

end
[/lua]

content:

[editline]26th May 2011[/editline]

Also if you need help fixing up the code to work for your needs(making sure the args are an actual player, and making sure it only prints on an admins screen) just tell me and I would be happy to help.

I just love experienced hookers.

Edit:
Thanks for the help guys cause I needed it too

You’ve found yourself one right here.

:v: no problem for helping ;D