2004-02-08 11:31:54 +00:00
|
|
|
/* AMX Mod X misc.
|
|
|
|
*
|
2004-02-21 20:30:04 +00:00
|
|
|
* by the AMX Mod X Development Team
|
|
|
|
* originally developed by OLO
|
2004-02-08 11:31:54 +00:00
|
|
|
*
|
|
|
|
* This file is provided as is (no warranties).
|
|
|
|
*/
|
2004-01-31 20:56:22 +00:00
|
|
|
|
2004-02-21 20:30:04 +00:00
|
|
|
#if defined _amxmisc_included
|
|
|
|
#endinput
|
|
|
|
#endif
|
|
|
|
#define _amxmisc_included
|
|
|
|
|
2004-02-15 02:29:51 +00:00
|
|
|
stock cmd_access(id,level,cid,num) {
|
2004-02-08 11:31:54 +00:00
|
|
|
if ( ((get_user_flags(id)&level)!=level) && (id!=(is_dedicated_server()?0:1)) ) {
|
|
|
|
console_print(id,"You have no access to that command")
|
2004-02-15 02:29:51 +00:00
|
|
|
return 0
|
2004-01-31 20:56:22 +00:00
|
|
|
}
|
2004-02-08 11:31:54 +00:00
|
|
|
if (read_argc() < num) {
|
2004-01-31 20:56:22 +00:00
|
|
|
new hcmd[32], hinfo[128], hflag
|
2004-02-08 11:31:54 +00:00
|
|
|
get_concmd(cid,hcmd,31,hflag,hinfo,127,level)
|
|
|
|
console_print(id,"Usage: %s %s",hcmd,hinfo)
|
2004-02-15 02:29:51 +00:00
|
|
|
return 0
|
2004-01-31 20:56:22 +00:00
|
|
|
}
|
2004-02-15 02:29:51 +00:00
|
|
|
return 1
|
2004-01-31 20:56:22 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
stock access(id,level)
|
|
|
|
return (get_user_flags(id) & level)
|
|
|
|
|
|
|
|
/* Flags:
|
2004-02-21 20:30:04 +00:00
|
|
|
* 1 - obey immunity
|
|
|
|
* 2 - allow yourself
|
|
|
|
* 4 - must be alive
|
|
|
|
* 8 - can't be bot */
|
2004-01-31 20:56:22 +00:00
|
|
|
stock cmd_target(id,const arg[],flags = 1) {
|
|
|
|
new player = find_player("bl",arg)
|
2004-02-08 11:31:54 +00:00
|
|
|
if (player) {
|
|
|
|
if ( player != find_player("blj",arg) ) {
|
2004-01-31 20:56:22 +00:00
|
|
|
console_print(id,"There are more clients matching to your argument")
|
|
|
|
return 0
|
|
|
|
}
|
|
|
|
}
|
|
|
|
else if ( ( player = find_player("c",arg) )==0 && arg[0]=='#' && arg[1] )
|
2004-03-08 17:18:34 +00:00
|
|
|
player = find_player("k",str_to_num(arg[1]))
|
2004-02-08 11:31:54 +00:00
|
|
|
if (!player) {
|
2004-01-31 20:56:22 +00:00
|
|
|
console_print(id,"Client with that name or userid not found")
|
|
|
|
return 0
|
|
|
|
}
|
2004-02-08 11:31:54 +00:00
|
|
|
if (flags & 1) {
|
|
|
|
if ((get_user_flags(player)&ADMIN_IMMUNITY) && ((flags&2)?(id!=player):true) ) {
|
2004-01-31 20:56:22 +00:00
|
|
|
new imname[32]
|
|
|
|
get_user_name(player,imname,31)
|
|
|
|
console_print(id,"Client ^"%s^" has immunity",imname)
|
|
|
|
return 0
|
|
|
|
}
|
|
|
|
}
|
2004-02-08 11:31:54 +00:00
|
|
|
if (flags & 4) {
|
|
|
|
if (!is_user_alive(player)) {
|
2004-01-31 20:56:22 +00:00
|
|
|
new imname[32]
|
|
|
|
get_user_name(player,imname,31)
|
|
|
|
console_print(id,"That action can't be performed on dead client ^"%s^"",imname)
|
|
|
|
return 0
|
|
|
|
}
|
|
|
|
}
|
2004-02-08 11:31:54 +00:00
|
|
|
if (flags & 8) {
|
|
|
|
if (is_user_bot(player)) {
|
2004-01-31 20:56:22 +00:00
|
|
|
new imname[32]
|
|
|
|
get_user_name(player,imname,31)
|
|
|
|
console_print(id,"That action can't be performed on bot ^"%s^"",imname)
|
|
|
|
return 0
|
|
|
|
}
|
|
|
|
}
|
|
|
|
return player
|
|
|
|
}
|
|
|
|
|
2004-02-08 11:31:54 +00:00
|
|
|
stock show_activity( id, const name[], {Float,_}: ... ) {
|
2004-01-31 20:56:22 +00:00
|
|
|
new buffer[128]
|
2004-02-08 11:31:54 +00:00
|
|
|
format_args( buffer , 127 , 2 )
|
2004-01-31 20:56:22 +00:00
|
|
|
switch(get_cvar_num("amx_show_activity")) {
|
|
|
|
case 2: client_print(0,print_chat,"%s %s: %s",
|
|
|
|
(get_user_flags(id) & ADMIN_USER) ? "PLAYER" : "ADMIN" , name , buffer )
|
|
|
|
case 1: client_print(0,print_chat,"%s: %s",
|
|
|
|
(get_user_flags(id) & ADMIN_USER) ? "PLAYER" : "ADMIN", buffer )
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2004-02-08 11:31:54 +00:00
|
|
|
stock is_running(const arg[]) {
|
2004-01-31 20:56:22 +00:00
|
|
|
new mod_name[32]
|
|
|
|
get_modname(mod_name,31)
|
|
|
|
return equal(mod_name,arg)
|
|
|
|
}
|
|
|
|
|
|
|
|
stock build_path( path[] , len , {Float,_}:... ) {
|
|
|
|
format_args( path , len , 2 )
|
2004-03-09 15:53:40 +00:00
|
|
|
return replace( path , len , "$basedir", "addons/amxx" )
|
2004-01-31 20:56:22 +00:00
|
|
|
}
|
|
|
|
|
2004-02-08 11:31:54 +00:00
|
|
|
stock get_basedir( name[], len )
|
2004-03-16 19:40:02 +00:00
|
|
|
return copy(name,len,"addons/amxx")
|
|
|
|
|
|
|
|
stock get_user_wonid(index)
|
|
|
|
{
|
|
|
|
new authid[32]
|
|
|
|
get_user_authid(index,authid,31)
|
|
|
|
return str_to_num(authid)
|
|
|
|
}
|