1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
Array = function(m, v)
	local t = {}
	for i = 1, m do
		t[i] = v
	end
	return t
end
Color = Array(32, "")
ColorTable = {
	"\169000000255",
	"\169255000000",
	"\169000255000",
	"\169255000255",
	"\169255255000",	-- yellow is CS2D's default color of chat messages
	"\169000255255",
	"\169255255255",
	"",
	""
}
ColorTableNames = {
	"Blue Color",
	"Red Color",
	"Green Color",
	"Pink Color",
	"Yellow Color",
	"Cyan Color",
	"White Color",
	"",
	"No Color"
}
TeamColors = {
	[0] = "\169255255000", -- spectators (default)
	[1] = "\169255000000",	-- terrorists
	[2] = "\169000000255",	-- counter-terrorists
	[3] = "\169000000255", -- vip
}
addhook("say", "HookSay", 999)
addhook("sayteam", "HookSayTeam", 998)
HookSayTeam = function(id, message)
	return HookSay(id, message, true)
end
HookSay = function(id, message, team)
	if message == "!color" then
		local S = "Change chat color,"
		for i = 1, #ColorTableNames do
			local t = (Color[id] == i) and "("..ColorTableNames[i].."[current])" or ColorTableNames[i]
			S = S..t..","
		end
		menu(id, S:sub(1, #S - 1))
		return 1
	else
		local m = message:gsub("@C", "") m = m:gsub("\\", "")
		local clr = Color[id]
		if clr == "" then clr = TeamColors[0] end
		
		local S = TeamColors[player(id, "team")]..player(id, "name")..(team and TeamColors[0].." (Team)" or "")..((player(id, "health") > 0) and "" or TeamColors[0].." *DEAD*"..clr)..TeamColors[0]..": "..clr..m
		if team then
			for i = 1, 32 do
				if player(i, "exists") and player(id, "team") == player(i, "team") then
					msg2(i, S)
				end
			end
		else
			msg(S)
		end
		return 1
	end
end
addhook("menu", "HookMenu")
HookMenu = function(id, title, b)
	if title == "Change chat color" and b ~= "x" and b~= 0 then
		Color[id] = ColorTable[b]
	end
end