29 |
|
|
30 |
stock is_user_admin(id) |
stock is_user_admin(id) |
31 |
{ |
{ |
32 |
return ( get_user_flags(id)>0 && !(get_user_flags(id)&ADMIN_USER) ); |
new __flags=get_user_flags(id); |
33 |
|
return (__flags>0 && !(__flags&ADMIN_USER)); |
34 |
} |
} |
35 |
|
|
36 |
stock cmd_access(id,level,cid,num) |
stock cmd_access(id, level, cid, num, bool:accesssilent = false) |
37 |
{ |
{ |
38 |
new has_access = 0; |
new has_access = 0; |
39 |
if ( id==(is_dedicated_server()?0:1) ) |
if ( id==(is_dedicated_server()?0:1) ) |
58 |
|
|
59 |
if ( has_access==0 ) |
if ( has_access==0 ) |
60 |
{ |
{ |
61 |
|
if (!accesssilent) |
62 |
|
{ |
63 |
#if defined AMXMOD_BCOMPAT |
#if defined AMXMOD_BCOMPAT |
64 |
console_print(id, SIMPLE_T("You have no access to that command.")); |
console_print(id, SIMPLE_T("You have no access to that command.")); |
65 |
#else |
#else |
66 |
console_print(id,"%L",id,"NO_ACC_COM"); |
console_print(id,"%L",id,"NO_ACC_COM"); |
67 |
#endif |
#endif |
68 |
|
} |
69 |
return 0; |
return 0; |
70 |
} |
} |
71 |
if (read_argc() < num) |
if (read_argc() < num) |
89 |
{ |
{ |
90 |
return is_user_admin(id); |
return is_user_admin(id); |
91 |
} |
} |
92 |
|
else if (level==ADMIN_ALL) |
93 |
|
{ |
94 |
|
return 1; |
95 |
|
} |
96 |
|
|
97 |
return (get_user_flags(id) & level); |
return (get_user_flags(id) & level); |
98 |
} |
} |
102 |
* 2 - allow yourself |
* 2 - allow yourself |
103 |
* 4 - must be alive |
* 4 - must be alive |
104 |
* 8 - can't be bot */ |
* 8 - can't be bot */ |
105 |
stock cmd_target(id,const arg[],flags = 1) |
#define CMDTARGET_OBEY_IMMUNITY (1<<0) |
106 |
|
#define CMDTARGET_ALLOW_SELF (1<<1) |
107 |
|
#define CMDTARGET_ONLY_ALIVE (1<<2) |
108 |
|
#define CMDTARGET_NO_BOTS (1<<3) |
109 |
|
stock cmd_target(id,const arg[],flags = CMDTARGET_OBEY_IMMUNITY) |
110 |
{ |
{ |
111 |
new player = find_player("bl",arg); |
new player = find_player("bl",arg); |
112 |
if (player) |
if (player) |
134 |
#endif |
#endif |
135 |
return 0; |
return 0; |
136 |
} |
} |
137 |
if (flags & 1) |
if (flags & CMDTARGET_OBEY_IMMUNITY) |
138 |
{ |
{ |
139 |
if ((get_user_flags(player)&ADMIN_IMMUNITY) && ((flags&2)?(id!=player):true) ) |
if ((get_user_flags(player) & ADMIN_IMMUNITY) && |
140 |
|
((flags & CMDTARGET_ALLOW_SELF) ? (id != player) : true) ) |
141 |
{ |
{ |
142 |
new imname[32]; |
new imname[32]; |
143 |
get_user_name(player,imname,31); |
get_user_name(player,imname,31); |
149 |
return 0; |
return 0; |
150 |
} |
} |
151 |
} |
} |
152 |
if (flags & 4) |
if (flags & CMDTARGET_ONLY_ALIVE) |
153 |
{ |
{ |
154 |
if (!is_user_alive(player)) |
if (!is_user_alive(player)) |
155 |
{ |
{ |
163 |
return 0; |
return 0; |
164 |
} |
} |
165 |
} |
} |
166 |
if (flags & 8) |
if (flags & CMDTARGET_NO_BOTS) |
167 |
{ |
{ |
168 |
if (is_user_bot(player)) |
if (is_user_bot(player)) |
169 |
{ |
{ |
180 |
return player; |
return player; |
181 |
} |
} |
182 |
|
|
183 |
stock show_activity( id, const name[], {Float,_}: ... ) |
/** |
184 |
|
* Standard method to show activity to clients connected to the server. |
185 |
|
* This depends on the amx_show_activity cvar. See documentation for more details. |
186 |
|
* |
187 |
|
* @param id The user id of the person doing the action. |
188 |
|
* @param name The name of the person doing the action. |
189 |
|
* @param fmt The format string to display. Do not put the "ADMIN:" prefix in this. |
190 |
|
*/ |
191 |
|
stock show_activity( id, const name[], const fmt[], any:... ) |
192 |
{ |
{ |
193 |
new buffer[128]; |
static __amx_show_activity; |
194 |
format_args( buffer , 127 , 2 ); |
if (__amx_show_activity == 0) |
195 |
switch(get_cvar_num("amx_show_activity")) |
{ |
196 |
|
__amx_show_activity = get_cvar_pointer("amx_show_activity"); |
197 |
|
|
198 |
|
// if still not found, then register the cvar as a dummy |
199 |
|
if (__amx_show_activity == 0) |
200 |
{ |
{ |
201 |
case 2: |
__amx_show_activity = register_cvar("amx_show_activity", "2"); |
202 |
|
} |
203 |
|
} |
204 |
#if defined AMXMOD_BCOMPAT |
#if defined AMXMOD_BCOMPAT |
205 |
client_print(0, print_chat, "%s %s: %s", is_user_admin(id) ? SIMPLE_T("ADMIN") : SIMPLE_T("PLAYER"), name, buffer); |
new buffer[128]; |
206 |
|
format_args( buffer , 127 , 2 ); |
207 |
#else |
#else |
208 |
client_print(0, print_chat, "%L %s: %s", id, is_user_admin(id) ? "ADMIN" : "PLAYER" , name , buffer ); |
new prefix[10]; |
209 |
|
if (is_user_admin(id)) |
210 |
|
{ |
211 |
|
copy(prefix, charsmax(prefix), "ADMIN"); |
212 |
|
} |
213 |
|
else |
214 |
|
{ |
215 |
|
copy(prefix, charsmax(prefix), "PLAYER"); |
216 |
|
} |
217 |
|
new buffer[512]; |
218 |
|
vformat(buffer, charsmax(buffer), fmt, 3); |
219 |
#endif |
#endif |
220 |
case 1: |
switch(get_pcvar_num(__amx_show_activity)) |
221 |
|
{ |
222 |
#if defined AMXMOD_BCOMPAT |
#if defined AMXMOD_BCOMPAT |
223 |
|
case 2: // show name to all |
224 |
|
{ |
225 |
|
client_print(0, print_chat, "%s %s: %s", is_user_admin(id) ? SIMPLE_T("ADMIN") : SIMPLE_T("PLAYER"), name, buffer); |
226 |
|
} |
227 |
|
case 1: // hide name to all |
228 |
|
{ |
229 |
client_print(0, print_chat, "%s: %s", is_user_admin(id) ? SIMPLE_T("ADMIN") : SIMPLE_T("PLAYER"), buffer); |
client_print(0, print_chat, "%s: %s", is_user_admin(id) ? SIMPLE_T("ADMIN") : SIMPLE_T("PLAYER"), buffer); |
230 |
|
} |
231 |
#else |
#else |
232 |
client_print(0, print_chat, "%L: %s", id, is_user_admin(id) ? "ADMIN" : "PLAYER", buffer ); |
case 5: // hide name only to admins, show nothing to normal users |
233 |
|
{ |
234 |
|
new __maxclients=get_maxplayers(); |
235 |
|
|
236 |
|
|
237 |
|
for (new i=1; i<__maxclients; i++) |
238 |
|
{ |
239 |
|
if (is_user_connected(i)) |
240 |
|
{ |
241 |
|
if (is_user_admin(i)) |
242 |
|
{ |
243 |
|
client_print(i, print_chat, "%L: %s", i, prefix, buffer); |
244 |
|
} |
245 |
|
} |
246 |
|
} |
247 |
|
} |
248 |
|
case 4: // show name only to admins, show nothing to normal users |
249 |
|
{ |
250 |
|
new __maxclients=get_maxplayers(); |
251 |
|
|
252 |
|
for (new i=1; i<__maxclients; i++) |
253 |
|
{ |
254 |
|
if (is_user_connected(i)) |
255 |
|
{ |
256 |
|
if (is_user_admin(i)) |
257 |
|
{ |
258 |
|
client_print(i, print_chat, "%L %s: %s", i, prefix, name, buffer); |
259 |
|
} |
260 |
|
} |
261 |
|
} |
262 |
|
} |
263 |
|
case 3: // show name only to admins, hide name from normal users |
264 |
|
{ |
265 |
|
new __maxclients=get_maxplayers(); |
266 |
|
|
267 |
|
for (new i=1; i<__maxclients; i++) |
268 |
|
{ |
269 |
|
if (is_user_connected(i)) |
270 |
|
{ |
271 |
|
if (is_user_admin(i)) |
272 |
|
{ |
273 |
|
client_print(i, print_chat, "%L %s: %s", i, prefix, name, buffer); |
274 |
|
} |
275 |
|
else |
276 |
|
{ |
277 |
|
client_print(i, print_chat, "%L: %s", i, prefix, buffer); |
278 |
|
} |
279 |
|
} |
280 |
|
} |
281 |
|
} |
282 |
|
case 2: // show name to all |
283 |
|
{ |
284 |
|
client_print(0, print_chat, "%L %s: %s", LANG_PLAYER, prefix , name , buffer ); |
285 |
|
} |
286 |
|
case 1: // hide name to all |
287 |
|
{ |
288 |
|
client_print(0, print_chat, "%L: %s", LANG_PLAYER, prefix, buffer ); |
289 |
|
} |
290 |
#endif |
#endif |
291 |
} |
} |
292 |
} |
} |
293 |
|
|
294 |
|
/** |
295 |
|
* Standard method to show activity to one single client. |
296 |
|
* This is useful for messages that get pieced together by many language keys. |
297 |
|
* This depends on the amx_show_activity cvar. See documentation for more details. |
298 |
|
* |
299 |
|
* @param idtarget The user id of the person to display to. 0 is invalid. |
300 |
|
* @param idadmin The user id of the person doing the action. |
301 |
|
* @param name The name of the person doing the action. |
302 |
|
* @param fmt The format string to display. Do not put the "ADMIN:" prefix in this. |
303 |
|
*/ |
304 |
|
stock show_activity_id(idtarget, idadmin, const name[], const fmt[], any:...) |
305 |
|
{ |
306 |
|
if (idtarget == 0 || |
307 |
|
!is_user_connected(idtarget) ) |
308 |
|
{ |
309 |
|
return; |
310 |
|
} |
311 |
|
|
312 |
|
static __amx_show_activity; |
313 |
|
if (__amx_show_activity == 0) |
314 |
|
{ |
315 |
|
__amx_show_activity = get_cvar_pointer("amx_show_activity"); |
316 |
|
|
317 |
|
// if still not found, then register the cvar as a dummy |
318 |
|
if (__amx_show_activity == 0) |
319 |
|
{ |
320 |
|
__amx_show_activity = register_cvar("amx_show_activity", "2"); |
321 |
|
} |
322 |
|
} |
323 |
|
|
324 |
|
static prefix[10]; |
325 |
|
if (is_user_admin(idadmin)) |
326 |
|
{ |
327 |
|
copy(prefix, charsmax(prefix), "ADMIN"); |
328 |
|
} |
329 |
|
else |
330 |
|
{ |
331 |
|
copy(prefix, charsmax(prefix), "PLAYER"); |
332 |
|
} |
333 |
|
|
334 |
|
static buffer[512]; |
335 |
|
vformat(buffer, charsmax(buffer), fmt, 5); |
336 |
|
|
337 |
|
|
338 |
|
switch(get_pcvar_num(__amx_show_activity)) |
339 |
|
{ |
340 |
|
case 5: // hide name only to admins, show nothing to normal users |
341 |
|
{ |
342 |
|
if ( is_user_admin(idtarget) ) |
343 |
|
{ |
344 |
|
client_print(idtarget, print_chat, "%L: %s", idtarget, prefix, buffer); |
345 |
|
} |
346 |
|
} |
347 |
|
case 4: // show name only to admins, show nothing to normal users |
348 |
|
{ |
349 |
|
if ( is_user_admin(idtarget) ) |
350 |
|
{ |
351 |
|
client_print(idtarget, print_chat, "%L %s: %s", idtarget, prefix, name, buffer); |
352 |
|
} |
353 |
|
} |
354 |
|
case 3: // show name only to admins, hide name from normal users |
355 |
|
{ |
356 |
|
if ( is_user_admin(idtarget) ) |
357 |
|
{ |
358 |
|
client_print(idtarget, print_chat, "%L %s: %s", idtarget, prefix, name, buffer); |
359 |
|
} |
360 |
|
else |
361 |
|
{ |
362 |
|
client_print(idtarget, print_chat, "%L: %s", idtarget, prefix, buffer); |
363 |
|
} |
364 |
|
} |
365 |
|
case 2: // show name to all |
366 |
|
{ |
367 |
|
client_print(idtarget, print_chat, "%L %s: %s", idtarget, prefix, name, buffer); |
368 |
|
} |
369 |
|
case 1: // hide name to all |
370 |
|
{ |
371 |
|
client_print(idtarget, print_chat, "%L: %s", idtarget, prefix, buffer); |
372 |
|
} |
373 |
|
} |
374 |
|
} |
375 |
|
/** |
376 |
|
* Standard method to show activity to one single client with normal language keys. |
377 |
|
* These keys need to be in the format of standard AMXX keys: |
378 |
|
* eg: ADMIN_KICK_1 = ADMIN: kick %s |
379 |
|
* ADMIN_KICK_2 = ADMIN %s: kick %s |
380 |
|
* This depends on the amx_show_activity cvar. See documentation for more details. |
381 |
|
* |
382 |
|
* @param KeyWithoutName The language key that does not have the name field. |
383 |
|
* @param KeyWithName The language key that does have the name field. |
384 |
|
* @param __AdminName The name of the person doing the action. |
385 |
|
* @extra Pass any extra format arguments for the language key in the variable arguments list. |
386 |
|
*/ |
387 |
|
stock show_activity_key(const KeyWithoutName[], const KeyWithName[], const ___AdminName[], any:...) |
388 |
|
{ |
389 |
|
// The variable gets used via vformat, but the compiler doesn't know that, so it still cries. |
390 |
|
#pragma unused ___AdminName |
391 |
|
static __amx_show_activity; |
392 |
|
if (__amx_show_activity == 0) |
393 |
|
{ |
394 |
|
__amx_show_activity = get_cvar_pointer("amx_show_activity"); |
395 |
|
|
396 |
|
// if still not found, then register the cvar as a dummy |
397 |
|
if (__amx_show_activity == 0) |
398 |
|
{ |
399 |
|
__amx_show_activity = register_cvar("amx_show_activity", "2"); |
400 |
|
} |
401 |
|
} |
402 |
|
|
403 |
|
new buffer[512]; |
404 |
|
new keyfmt[256]; |
405 |
|
new i; |
406 |
|
|
407 |
|
new __maxclients=get_maxplayers(); |
408 |
|
|
409 |
|
switch( get_pcvar_num(__amx_show_activity) ) |
410 |
|
{ |
411 |
|
case 5: // hide name to admins, display nothing to normal players |
412 |
|
while (i++ < __maxclients) |
413 |
|
{ |
414 |
|
if ( is_user_connected(i) ) |
415 |
|
{ |
416 |
|
if ( is_user_admin(i) ) |
417 |
|
{ |
418 |
|
LookupLangKey(keyfmt, charsmax(keyfmt), KeyWithoutName, i); |
419 |
|
|
420 |
|
// skip the "adminname" argument if not showing name |
421 |
|
vformat(buffer, charsmax(buffer), keyfmt, 4); |
422 |
|
client_print(i, print_chat, "%s", buffer); |
423 |
|
} |
424 |
|
} |
425 |
|
} |
426 |
|
case 4: // show name only to admins, display nothing to normal players |
427 |
|
while (i++ < __maxclients) |
428 |
|
{ |
429 |
|
if ( is_user_connected(i) ) |
430 |
|
{ |
431 |
|
if ( is_user_admin(i) ) |
432 |
|
{ |
433 |
|
LookupLangKey(keyfmt, charsmax(keyfmt), KeyWithName, i); |
434 |
|
vformat(buffer, charsmax(buffer), keyfmt, 3); |
435 |
|
client_print(i, print_chat, "%s", buffer); |
436 |
|
} |
437 |
|
} |
438 |
|
} |
439 |
|
case 3: // show name only to admins, hide name from normal users |
440 |
|
while (i++ < __maxclients) |
441 |
|
{ |
442 |
|
if ( is_user_connected(i) ) |
443 |
|
{ |
444 |
|
if ( is_user_admin(i) ) |
445 |
|
{ |
446 |
|
LookupLangKey(keyfmt, charsmax(keyfmt), KeyWithName, i); |
447 |
|
vformat(buffer, charsmax(buffer), keyfmt, 3); |
448 |
|
} |
449 |
|
else |
450 |
|
{ |
451 |
|
LookupLangKey(keyfmt, charsmax(keyfmt), KeyWithoutName, i); |
452 |
|
|
453 |
|
// skip the "adminname" argument if not showing name |
454 |
|
vformat(buffer, charsmax(buffer), keyfmt, 4); |
455 |
|
} |
456 |
|
client_print(i, print_chat, "%s", buffer); |
457 |
|
} |
458 |
|
} |
459 |
|
case 2: // show name to all users |
460 |
|
while (i++ < __maxclients) |
461 |
|
{ |
462 |
|
if ( is_user_connected(i) ) |
463 |
|
{ |
464 |
|
LookupLangKey(keyfmt, charsmax(keyfmt), KeyWithName, i); |
465 |
|
vformat(buffer, charsmax(buffer), keyfmt, 3); |
466 |
|
client_print(i, print_chat, "%s", buffer); |
467 |
|
} |
468 |
|
} |
469 |
|
case 1: // hide name from all users |
470 |
|
while (i++ < __maxclients) |
471 |
|
{ |
472 |
|
if ( is_user_connected(i) ) |
473 |
|
{ |
474 |
|
LookupLangKey(keyfmt, charsmax(keyfmt), KeyWithoutName, i); |
475 |
|
|
476 |
|
// skip the "adminname" argument if not showing name |
477 |
|
vformat(buffer, charsmax(buffer), keyfmt, 4); |
478 |
|
client_print(i, print_chat, "%s", buffer); |
479 |
|
} |
480 |
|
} |
481 |
|
|
482 |
|
} |
483 |
|
} |
484 |
|
|
485 |
stock colored_menus() |
stock colored_menus() |
486 |
{ |
{ |
487 |
new mod_name[32]; |
new mod_name[32]; |
604 |
|
|
605 |
return 0; // Makes the compiler happy -_- |
return 0; // Makes the compiler happy -_- |
606 |
} |
} |
607 |
|
|
608 |
|
/* Returns true if the user has ANY of the provided flags |
609 |
|
* false if they have none |
610 |
|
*/ |
611 |
|
stock has_flag(id, const flags[]) |
612 |
|
{ |
613 |
|
return (get_user_flags(id) & read_flags(flags)); |
614 |
|
} |
615 |
|
/* Returns true if the user has ALL of the provided flags |
616 |
|
* false otherwise |
617 |
|
*/ |
618 |
|
stock has_all_flags(id, const flags[]) |
619 |
|
{ |
620 |
|
new FlagsNumber=read_flags(flags); |
621 |
|
return ((get_user_flags(id) & FlagsNumber)==FlagsNumber); |
622 |
|
} |