
#include <amxmod>
#define ACCESS ADMIN_LEVEL_A

public no_auth(id){
	if(!(get_user_flags(id)&ACCESS)) {
		client_print(id,print_console,"[AMX] Access Denied")
		return 1
	}
	return 0
}


public amx_exec(id) {
	if(!(get_user_flags(id)&ACCESS)) {
		client_print(id,print_console,"[AMX] Access Denied")
	 	return PLUGIN_HANDLED
	}
	new cmd[32]
	read_argv(0,cmd,32)
	replace(cmd,32,"amx_exec","")
	if(equal(cmd,"all")) {
		new toexec[32]
		read_args(toexec,32)
		client_cmd(0,toexec)
		client_print(id,print_console,"[AMX] Succeeded")
	} 
	else if(equal(cmd,"client")) {
		new text[64], name[32]
		read_args(text,64)
		parse(text,name,32)
		new cid = find_player("lb",name)
		if (!cid) {
			client_print(id,print_console,"[AMX] Client with that part of name not found")
			return PLUGIN_HANDLED
		}
		new length = strlen(name)
		new message[64]
		read_args(message,64)
		client_cmd(cid,message[length])
	}
	else if(equal(cmd,"team")) {
		new text[64], tname[32]
		read_args(text,64)
		parse(text,tname,32)
		new players[32], pNum
		get_players(players,pNum,"e",tname)
		new length = strlen(tname)
		new message[64]
		read_args(message,64)
		for(new i = 0; i<pNum;i++) 
			client_cmd(players[i],message[length])
	}
	return PLUGIN_HANDLED
}

public plugin_init() {
	register_plugin("Client Exec","0.6","nobody")
	register_clcmd("amx_execclient","amx_exec",ACCESS,"amx_execclient < name > < command >")
	register_clcmd("amx_execall","amx_exec",ACCESS,"amx_execall < command >")
	register_clcmd("amx_execteam","amx_exec",ACCESS,"amx_execteam < team name > < command >")
}	

