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

Annotation of /allchat.sma

Parent Directory Parent Directory | Revision Log Revision Log


Revision 1 - (view) (download)

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

Contact
ViewVC Help
Powered by ViewVC 1.0.4