@@ -17,17 +17,25 @@ native get_user_skill(player, &Float: skill);
1717native get_user_stats (player, stats[STATSX_MAX_STATS], bodyhits[MAX_BODYHITS]);
1818//
1919
20- enum any: rankRestrictionsType {
20+
21+ enum any: eChatType {
22+ voice_chat,
23+ text_chat
24+ }
25+
26+ enum any: eRankRestrictionsType {
2127 rr_type_none,
2228 rr_type_level,
2329 rr_type_frags
2430}
2531
2632new ca_rankrestrictions_type,
2733 ca_rankrestrictions_type_kills,
28- ca_rankrestrictions_min_kills,
34+ ca_rankrestrictions_min_kills_voice_chat,
35+ ca_rankrestrictions_min_kills_text_chat,
2936 ca_rankrestrictions_type_level,
30- ca_rankrestrictions_min_level,
37+ ca_rankrestrictions_min_level_voice_chat,
38+ ca_rankrestrictions_min_level_text_chat,
3139 ca_rankrestrictions_immunity_flag[16 ],
3240 ca_rankrestrictions_steam_immunity
3341
@@ -84,7 +92,7 @@ public native_filter(const name[], index, trap) {
8492
8593Create_CVars () {
8694 bind_pcvar_num (create_cvar (" ca_rankrestrictions_type" , " 1" ,
87- .description = " Restrictions Types \n \
95+ .description = " Restrictions Type \n \
8896 0 - Disable restrictions\n \
8997 1 - Level restrictions\n \
9098 2 - Kills count restrictions" ,
@@ -102,10 +110,16 @@ Create_CVars() {
102110 ), ca_rankrestrictions_type_kills
103111 )
104112
105- bind_pcvar_num (create_cvar (" ca_rankrestrictions_min_kills" , " 10" ,
106- .description = " Min kills count to access voice & text chat" ,
113+ bind_pcvar_num (create_cvar (" ca_rankrestrictions_min_kills_voice_chat" , " 10" ,
114+ .description = " Min kills count to access VOICE chat" ,
115+ .has_min = true , .min_val = 0 .0
116+ ), ca_rankrestrictions_min_kills_voice_chat
117+ )
118+
119+ bind_pcvar_num (create_cvar (" ca_rankrestrictions_min_kills_text_chat" , " 10" ,
120+ .description = " Min kills count to access TEXT chat" ,
107121 .has_min = true , .min_val = 0 .0
108- ), ca_rankrestrictions_min_kills
122+ ), ca_rankrestrictions_min_kills_text_chat
109123 )
110124
111125 bind_pcvar_num (create_cvar (" ca_rankrestrictions_type_level" , " 1" ,
@@ -122,10 +136,16 @@ Create_CVars() {
122136 ), ca_rankrestrictions_type_level
123137 )
124138
125- bind_pcvar_num (create_cvar (" ca_rankrestrictions_min_level " , " 2" ,
126- .description = " Min Level to access voice & text chat" ,
139+ bind_pcvar_num (create_cvar (" ca_rankrestrictions_min_level_voice_chat " , " 2" ,
140+ .description = " Min Level to access VOICE chat" ,
127141 .has_min = true , .min_val = 0 .0
128- ), ca_rankrestrictions_min_level
142+ ), ca_rankrestrictions_min_level_voice_chat
143+ )
144+
145+ bind_pcvar_num (create_cvar (" ca_rankrestrictions_min_level_text_chat" , " 2" ,
146+ .description = " Min Level to access TEXT chat" ,
147+ .has_min = true , .min_val = 0 .0
148+ ), ca_rankrestrictions_min_level_text_chat
129149 )
130150
131151 bind_pcvar_string (create_cvar (" ca_rankrestrictions_immunity_flag" , " a" ,
@@ -143,19 +163,23 @@ Create_CVars() {
143163}
144164
145165public CA_Client_Say (player, const bool: isTeamMessage, const message[]) {
146- if (! CanCommunicate (player)) {
166+ if (! CanCommunicate (player, true , text_chat )) {
147167 return CA_SUPERCEDE
148168 }
149169
150170 return CA_CONTINUE
151171}
152172
153173public CA_Client_Voice (const listener, const sender) {
154- // need chat notification?
155- return CanCommunicate (sender, false ) ? CA_CONTINUE : CA_SUPERCEDE
174+ if (! CanCommunicate (sender, false , voice_chat)) {
175+ // need chat notification?
176+ return CA_SUPERCEDE
177+ }
178+
179+ return CA_CONTINUE
156180}
157181
158- bool: CanCommunicate (const player, const bool: print = true ) {
182+ bool: CanCommunicate (const player, const bool: print, chatType ) {
159183 if (ca_rankrestrictions_type <= rr_type_none) {
160184 return true
161185 }
@@ -169,24 +193,50 @@ bool: CanCommunicate(const player, const bool: print = true) {
169193 return true
170194 }
171195
172- if (ca_rankrestrictions_type == rr_type_level && GetUserLevel (player) < ca_rankrestrictions_min_level) {
173- if (print) {
174- client_print_color (player, print_team_red, " % L" ,
175- player, " RankRestrictions_Warning_MinLevel" , ca_rankrestrictions_min_level
176- )
196+ switch (chatType) {
197+ case voice_chat: {
198+ if (ca_rankrestrictions_type == rr_type_level && GetUserLevel (player) < ca_rankrestrictions_min_level_voice_chat) {
199+ if (print) {
200+ client_print_color (player, print_team_red, " % L" ,
201+ player, " RankRestrictions_Warning_MinLevel" , ca_rankrestrictions_min_level_voice_chat
202+ )
203+ }
204+
205+ return false
206+ }
207+
208+ if (ca_rankrestrictions_type == rr_type_frags && GetUserFragsFromStats (player) < ca_rankrestrictions_min_kills_voice_chat) {
209+ if (print) {
210+ client_print_color (player, print_team_red, " % L" ,
211+ player, " RankRestrictions_Warning_MinKills" , ca_rankrestrictions_min_kills_voice_chat
212+ )
213+ }
214+
215+ return false
216+ }
177217 }
178218
179- return false
180- }
181-
182- if (ca_rankrestrictions_type == rr_type_frags && GetUserFragsFromStats (player) < ca_rankrestrictions_min_kills) {
183- if (print) {
184- client_print_color (player, print_team_red, " % L" ,
185- player, " RankRestrictions_Warning_MinKills" , ca_rankrestrictions_min_kills
186- )
219+ case text_chat: {
220+ if (ca_rankrestrictions_type == rr_type_level && GetUserLevel (player) < ca_rankrestrictions_min_level_text_chat) {
221+ if (print) {
222+ client_print_color (player, print_team_red, " % L" ,
223+ player, " RankRestrictions_Warning_MinLevel" , ca_rankrestrictions_min_level_text_chat
224+ )
225+ }
226+
227+ return false
228+ }
229+
230+ if (ca_rankrestrictions_type == rr_type_frags && GetUserFragsFromStats (player) < ca_rankrestrictions_min_kills_text_chat) {
231+ if (print) {
232+ client_print_color (player, print_team_red, " % L" ,
233+ player, " RankRestrictions_Warning_MinKills" , ca_rankrestrictions_min_kills_text_chat
234+ )
235+ }
236+
237+ return false
238+ }
187239 }
188-
189- return false
190240 }
191241
192242 return true
0 commit comments