[Half-Life AMXX] / allchat.sma Repository:
ViewVC logotype

Annotation of /allchat.sma

Parent Directory Parent Directory | Revision Log Revision Log


Revision 25 - (view) (download)

1 : ian 1 /*
2 :     AllChat v1.1
3 :     Copyright (C) 2006-2007 Ian (Juan) Cammarata
4 :    
5 : ian 25 This program is free software: you can redistribute it and/or modify
6 :     it under the terms of the GNU Affero General Public License as
7 :     published by the Free Software Foundation, either version 3 of the
8 :     License, or (at your option) any later version.
9 : ian 1
10 : ian 25 This program is distributed in the hope that it will be useful,
11 :     but WITHOUT ANY WARRANTY; without even the implied warranty of
12 :     MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 :     GNU Affero General Public License for more details.
14 : ian 1
15 : ian 25 You should have received a copy of the GNU Affero General Public License
16 :     along with this program. If not, see <http://www.gnu.org/licenses/>.
17 :     --------------------------------------------------------------------------------
18 : ian 1
19 : ian 25 http://ian.cammarata.us
20 : ian 1
21 :     Description:
22 :     This plugin does for chat what sv_alltalk does for voice. Dead and alive and spectating players can all see each others chat messages. Team chat is still only visible among your team, but with no regard for whether you are dead or alive. By default this plugin works depending on whether or not sv_alltalk is on. It can be forced to be on all the time, as well as setting custom colors for messages that come from admins.
23 :    
24 :    
25 :     See it in Action:
26 :     Use the following link to find a server that's running this plugin:
27 :     http://www.game-monitor.com/search.php?search=allchat_version&type=variable&game=all&country=all
28 :    
29 :    
30 :     Cvars:
31 :     *First value is default
32 :    
33 :     sv_allchat <1|2|0>
34 :     1 - Dependent on sv_alltalk
35 :     2 - Always active
36 :     0 - Disabled
37 :    
38 :     ac_namecolor <0|1|2>
39 :     ac_msgcolor <1|2|0>
40 :     0 - Team color
41 :     1 - Green
42 :     2 - White
43 :    
44 :     ac_hidestatus <0|1>
45 :     0 = Show dead/spec status.
46 :     1 = Hide status.
47 :    
48 :     ac_teamchat <0|1>
49 :     0 = Dead and living can't team chat.
50 :     1 = Dead and living can team chat.
51 :    
52 :    
53 :     Change Log:
54 :     Key (+ added | - removed | f fixed | c changed)
55 :    
56 :     v1.1 (Aug 14, 2007)
57 :     +: Cvar ac_hidestatus to show/hide dead/spec status.
58 :     +: Cvar ac_teamchat to enable/disable all chat for team chat.
59 :    
60 :     v1.0.1 (June 28, 2007)
61 :     f: Replicated messages are now correctly collored based on admin flag.
62 :    
63 :     v1.0 (June 26, 2007)
64 :     !Complete rewrite.
65 :     f: No longer interferes with other plugins.
66 :    
67 :     v0.5 (June 21, 2007)
68 :     +: Tracking cvar.
69 :     c: Uses cvar pointers now.
70 :    
71 :     v0.4 (??? ??, 2006) by Ian Cammarata & Dontask
72 :     f : Blocking text messages conataining only spaces.
73 :    
74 :     v0.3 (June 23, 2006) by Ian Cammarata & Dontask
75 :     + : Added multiple values to sv_allchat. See details in Cvar section.
76 :     + : Added cvar ac_namecolor to change the color displayed on admins names.
77 :     + : Added cvar ac_msgcolor to change the color displayed on admins msgs.
78 :     + : Added colored messages even if sv_allchat is set to 1 while alltalk is set to 0.
79 :     + : Added equivalent functionality for team say.
80 :    
81 :     v0.2.1 (??? ??, 2006) by Ian Cammarata & Dontask
82 :     f : Fixed formatting color issues.
83 :    
84 :     v0.2 (??? ??, 2006) by Ian Cammarata & Dontask
85 :     r : Admins name displayed in team color, message text displayed green.
86 :     + : Displays dead status.
87 :     + : Added cvar sv_allchat to enable allchat without alltalk enabled.
88 :    
89 :     v0.1 (April 04, 2006)
90 :     + : Initial release
91 :     */
92 :    
93 :     #include <amxmodx>
94 :    
95 :     #define FLAG ADMIN_RESERVATION
96 :     #define VERSION "1.1"
97 :    
98 :     new COLCHAR[3][2] = { "^x03"/*team col*/, "^x04"/*green*/, "^x01"/*white*/ }
99 :    
100 :     //cvar pointers
101 :     new p_allchat, p_namecol, p_msgcol, p_alltalk, p_hidestat, p_teamchat
102 :    
103 :     //vars to check if message has already been duplicated
104 :     new alv_sndr, alv_str2[26], alv_str4[101]
105 :     new msg[200]
106 :    
107 :     public col_changer( msg_id, msg_dest, rcvr )
108 :     {
109 :     new str2[26]
110 :     get_msg_arg_string( 2, str2, 25 )
111 :     if( equal( str2, "#Cstrike_Chat", 13 ) )
112 :     {
113 :     new str3[22]
114 :     get_msg_arg_string( 3, str3, 21 )
115 :    
116 :     if( !strlen( str3 ) )
117 :     {
118 :     new str4[101]
119 :     get_msg_arg_string( 4, str4, 100 )
120 :     new sndr = get_msg_arg_int( 1 )
121 :    
122 :     new bool:is_team_msg = !bool:equal( str2, "#Cstrike_Chat_All", 17 )
123 :    
124 :     new sndr_team = get_user_team( sndr )
125 :     new bool:is_sndr_spec = !bool:( 0 < sndr_team < 3 )
126 :    
127 :     new namecol = clamp( get_pcvar_num(p_namecol), 0, 2 )
128 :     new msgcol = clamp( get_pcvar_num(p_msgcol), 0, 2 )
129 :    
130 :     new bool:same_as_last = bool:( alv_sndr == sndr && equal( alv_str2, str2 ) && equal( alv_str4, str4) )
131 :    
132 :     if( !same_as_last )
133 :     {//Duplicate message once
134 :     new allchat = clamp( get_pcvar_num( p_allchat ), 0, 2 )
135 :     if( allchat == 2 || ( allchat == 1 && clamp( get_pcvar_num( p_alltalk ), 0, 1 ) == 1 ) )
136 :     {
137 :     if( !( is_team_msg && ( is_sndr_spec || is_team_msg && get_pcvar_num( p_teamchat ) == 0 ) ) )
138 :     {//Don't duplicate if it's a spectator team message
139 :     new flags[5], team[10]
140 :     if( is_user_alive( sndr ) ) flags = "bch"
141 :     else flags = "ach"
142 :    
143 :     if( is_team_msg )
144 :     {
145 :     add( flags[strlen( flags )], 4, "e" )
146 :     if( sndr_team == 1 ) team = "TERRORIST"
147 :     else team = "CT"
148 :     }
149 :    
150 :     new players[32], num
151 :     get_players( players, num, flags, team )
152 :    
153 :     if( get_user_flags( sndr ) & FLAG )
154 :     buildmsg( sndr, is_sndr_spec, is_team_msg, sndr_team, namecol, msgcol, str4 ) //admin colored, by cvars
155 :     else buildmsg( sndr, is_sndr_spec, is_team_msg, sndr_team, 0, 2, str4 ) //normal colors
156 :    
157 :     for( new i=0; i < num; i++ )
158 :     {
159 :     message_begin( MSG_ONE, get_user_msgid( "SayText" ), _, players[i] )
160 :     write_byte( sndr )
161 :     write_string( msg )
162 :     message_end()
163 :     }
164 :    
165 :     }
166 :    
167 :     alv_sndr = sndr
168 :     alv_str2 = str2
169 :     alv_str4 = str4
170 :     if( task_exists( 411 ) ) remove_task( 411 )
171 :     set_task( 0.1, "task_clear_antiloop_vars", 411 )
172 :     }
173 :     }
174 :    
175 :     if( get_user_flags( sndr ) & FLAG && ( namecol != 0 || msgcol != 2 ) )
176 :     {//execute if sndr is admin and cols are not set to engine defaults
177 :     if( !same_as_last ) buildmsg( sndr, is_sndr_spec, is_team_msg, sndr_team, namecol, msgcol, str4 )
178 :    
179 :     set_msg_arg_string( 2, msg )
180 :     set_msg_arg_string( 4, "" )
181 :     }
182 :     }
183 :     }
184 :     return PLUGIN_CONTINUE
185 :     }
186 :    
187 :     public buildmsg( sndr, is_sndr_spec, is_team_msg, sndr_team, namecol, msgcol, str4[ ] )
188 :     {
189 :     new sndr_name[33]
190 :     get_user_name( sndr, sndr_name, 32 )
191 :    
192 :     new prefix[30] = "^x01"
193 :     if( get_pcvar_num( p_hidestat ) == 0 )
194 :     {
195 :     if( is_sndr_spec ) prefix = "^x01*SPEC* "
196 :     else if( !is_user_alive( sndr ) ) prefix = "^x01*DEAD* "
197 :     }
198 :    
199 :     if( is_team_msg )
200 :     {
201 :     if( is_sndr_spec ) prefix = "^x01(Spectator) "
202 :     else if( sndr_team == 1 ) add( prefix[strlen(prefix)-1], 29, "(Terrorist) " )
203 :     else if( sndr_team == 2 ) add( prefix[strlen(prefix)-1], 29, "(Counter-Terrorist) " )
204 :     }
205 :    
206 :     format( msg, 199, "%s%s%s : %s%s",\
207 :     strlen( prefix ) > 1 ? prefix : "",\
208 :     COLCHAR[namecol], sndr_name, COLCHAR[msgcol], str4 )
209 :     return PLUGIN_HANDLED
210 :     }
211 :    
212 :     public task_clear_antiloop_vars( )
213 :     {
214 :     alv_sndr = 0
215 :     alv_str2 = ""
216 :     alv_str4 = ""
217 :     return PLUGIN_HANDLED
218 :     }
219 :    
220 :     public plugin_init( )
221 :     {
222 :     register_plugin("All Chat",VERSION,"Ian Cammarata")
223 :     register_cvar("allchat_version",VERSION,FCVAR_SERVER)
224 :    
225 :     p_allchat = register_cvar( "sv_allchat", "1" )
226 :     p_namecol = register_cvar( "ac_namecolor", "0" )
227 :     p_msgcol = register_cvar( "ac_msgcolor", "1" )
228 :     p_hidestat = register_cvar( "ac_hidestatus", "0" )
229 :     p_teamchat = register_cvar( "ac_teamchat", "0" )
230 :    
231 :     p_alltalk = get_cvar_pointer( "sv_alltalk" )
232 :    
233 :     register_message( get_user_msgid("SayText"), "col_changer" )
234 :     return PLUGIN_CONTINUE
235 : ian 25 }

Contact
ViewVC Help
Powered by ViewVC 1.0.4