/////////////////////////////////////////////////////////////////////////////////////////////
//* Plugin generated by AMXX-Studio *///////////////////////////////////////////////////////
//*Edit changed console command to client command*/////////////////////////////////////////
//////////////////////////////////////////////////////////////////////////////////////////
//*commands are (console = mespec) (chat = /mespec)*/////////////////////////////////////
////////////////////////////////////////////////////////////////////////////////////////
//*22/08/07 Added Cvar quickspec 1/0 (1 = on) (0 = off)*///////////////////////////////
//////////////////////////////////////////////////////////////////////////////////////
//*make sure you difine your admin level where ADMIN_LEVEL_H is to your settings/////
////////////////////////////////////////////////////////////////////////////////////
#include <amxmodx>
#include <amxmisc>
#include <dodfun>

#define PLUGIN "Shadow Panthers Secret Spectate"
#define VERSION "3.0"
#define AUTHOR "blobby,Feuersturm"

// Define your admin level it is required below ADMIN_LEVEL_H is a custom level//
#define INVISIBILE_ADMIN ADMIN_LEVEL_H

new p_me_spec, gmsgText, inSecretSpec[33]

public plugin_init()
{	
	register_plugin(PLUGIN, VERSION, AUTHOR)
	register_clcmd("mespec", "me_spec", INVISIBILE_ADMIN)
	register_clcmd("say /mespec","me_spec", INVISIBILE_ADMIN)
	register_clcmd("say_team /mespec" , "me_spec", INVISIBILE_ADMIN)
	p_me_spec = register_cvar("dod_quickspec","1")
	gmsgText = get_user_msgid("TextMsg")
	register_message(gmsgText,"block_message")
}

public client_authorized(id)
{
	inSecretSpec[id] = 0
}

public me_spec(id,level,cid)
{
	if(!cmd_access(id,level,cid,1))
	{
		return PLUGIN_HANDLED
	}
	if(get_pcvar_num(p_me_spec) == 1)
	{
		dod_set_user_team(id, 3, 0)
		inSecretSpec[id] = 1
		client_print(id, print_chat, "[DOD SECRET SPEC] You are now in spectator mode no one knows you are there!")
	}
	else if(get_pcvar_num(p_me_spec) == 0)
	{
		client_print(id, print_chat, "[DOD SECRET SPEC] Plugin is disabled, sorry!")
	}
	return PLUGIN_HANDLED
}

public block_message(msg_id, msg_Dest, msg_Ent)
{
		new game_msg[64]
		get_msg_arg_string(2, game_msg, 63)
		if(equal(game_msg, "#game_joined_team") == 1)
		{
			new playername[32]
			get_msg_arg_string(3, playername, 31)
			new id = get_user_index(playername)
			if(inSecretSpec[id] == 1 && get_user_flags(id)&INVISIBILE_ADMIN)
			{
				inSecretSpec[id] = 0
				client_print(id,print_chat,"[DoD SECRET SPEC] You are really on a team now!")
				return PLUGIN_HANDLED
			}
			return PLUGIN_CONTINUE
		}
		return PLUGIN_CONTINUE
}
/* AMXX-Studio Notes - DO NOT MODIFY BELOW HERE
*{\\ rtf1\\ ansi\\ deff0{\\ fonttbl{\\ f0\\ fnil Tahoma;}}\n\\ viewkind4\\ uc1\\ pard\\ lang1031\\ f0\\ fs16 \n\\ par }
*/
