How can I color specific parts of the TTT radio commands? Like changing the color of “suspicious” to yellow, etc.
Here’s what I’ve got so far, I’ve put this in my autorun folder:
AddCSLuaFile()
if SERVER then
util.AddNetworkString( "CustomTraitorCallout" )
function RadioModify( ply, cmd, target )
if cmd == "quick_traitor" then
net.Start( "CustomTraitorCallout" )
net.WriteTable( { ply, target } )
net.Broadcast()
return true
end
end
hook.Add( "TTTPlayerRadioCommand", "RadioModify", RadioModify )
end
net.Receive( "CustomTraitorCallout", function()
local ply = net.ReadTable()[1]
local tar = net.ReadTable()[2]
chat.AddText( Color( 255, 255, 255 ), ply, ": ", tar, " is a ", Color( 255, 0, 0 ), "Traitor!" )
end )
But all it does is print " is a Traitor!", without the target name. It looks like tar is nil on the client side for some reason, even though I seemingly sent the value over.
It’s because when you net.ReadTable() the second time the net library tries to read from a second net.WriteTable().
Do this instead:
local sentTable = net.ReadTable()
local ply = sentTable[1]
local tar = sentTable[2]
And the target variable can be either the entity index or an identifier like “quick_nobody” if the player is not found. Keep that in mind.
Thanks, that worked, but one question, how can I change the color of the entity to white? It displays chat playernames, when I just want them to be white text.
Not sure I follow.
You would just use chat.AddText and set the color to white before you’re using the nick.
I do, but in TTT it still colors the name green, like it would be as if a player types a message in chat.
Instead of ply, use ply:Nick()
Also you should localize that serverside function, no reason to make it global