AMXX-BG.INFO colorchat.inc Raw include

colorchat.inc

Original include source with line numbers.

Back Download .inc
1 enum Color { NORMAL = 1, GREEN, TEAM_COLOR, GREY, RED, BLUE }
2 new TeamName[][] = { "", "TERRORIST", "CT", "SPECTATOR" }
3
4 ColorChat(id, Color:iType, const szMsg[], any:...)
5 {
6 static szMessage[256]
7
8 switch(iType)
9 {
10 case NORMAL: szMessage[0] = 0x01
11 case GREEN: szMessage[0] = 0x04
12 default: szMessage[0] = 0x03
13 }
14
15 vformat(szMessage[1], charsmax(szMessage), szMsg, 4)
16 replace_all(szMessage, charsmax(szMessage), "!n", "^x01")
17 replace_all(szMessage, charsmax(szMessage), "!t", "^x03")
18 replace_all(szMessage, charsmax(szMessage), "!g", "^x04")
19
20 static iTeam, ColorChange, iIndex, iMsgType
21 szMessage[192] = EOS
22
23 if(id)
24 {
25 iMsgType = MSG_ONE
26 iIndex = id
27 }
28 else
29 {
30 iIndex = FindPlayer()
31 iMsgType = MSG_ALL
32 }
33
34 iTeam = get_user_team(iIndex)
35 ColorChange = ColorSelection(iIndex, iMsgType, iType)
36 ShowColorMessage(iIndex, iMsgType, szMessage)
37
38 if(ColorChange)
39 Team_Info(iIndex, iMsgType, TeamName[iTeam])
40 }
41
42 ShowColorMessage(id, iType, szMessage[])
43 {
44 message_begin(iType, get_user_msgid("SayText"), _, id)
45 write_byte(id)
46 write_string(szMessage)
47 message_end()
48 }
49
50 Team_Info(id, iType, iTeam[])
51 {
52 message_begin(iType, get_user_msgid("TeamInfo"), _, id)
53 write_byte(id)
54 write_string(iTeam)
55 message_end()
56 return 1
57 }
58
59 ColorSelection(iIndex, iType, Color:Type)
60 {
61 switch(Type)
62 {
63 case RED: return Team_Info(iIndex, iType, TeamName[1]);
64 case BLUE: return Team_Info(iIndex, iType, TeamName[2]);
65 case GREY: return Team_Info(iIndex, iType, TeamName[0]);
66 }
67
68 return 0
69 }
70
71 FindPlayer()
72 {
73 static i
74 i = -1
75
76 while(i <= get_maxplayers())
77 {
78 if(is_user_connected(++i))
79 return i;
80 }
81
82 return -1
83 }