/*================================================================================
	
	---------------------------------
	-*- [ZP] Extra Item : T-Virus -*-
	---------------------------------
	
	-----------------
	- Description -
	-----------------
	
	This plugin adds an extra item to zombie plague advance mode, it's called T-Virus.
	It turns every human who buys it to a zombie. 
	
	
	~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
	~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
	
	
	-------------
	 *||CVARS||*
	-------------
	- T-Virus 1 
		Set this to 0 will disable the plugin, 1 means to enable it .
		
	- T-Nemesis 0 
		Set this to 0 will disable T-Virus during Nemesis round , 1 means to enable it .
		
	- T-Swarm 0 
		Set this to 0 will disable T-Virus during Swarm round , 1 means to enable it.
		
	- T-Plague 0 
		Set this to 0 will disable T-Virus during Plague round , 1 means to enable it.
		
	- T-Assassin 0 
		Set this to 0 will disable T-Virus during Assassin round , 1 means to enable it.
	
	- T-Allow_Virus_Before_Infection_Spread 0 
		Set this to 0 means that no one can buy the T-Virus before any GameMode starts , 1 means that players can buy the T-Virus even before the infection spread ( not recommended ) 
		( Note : if you want to set this to 1 i suggest to increase the price of the T-Virus, any way it's up to you .)
		. 
	- T-Sound 1 
		Set this to 0 means to disable the T-Virus sound when you buy it, 1 means that you will hear the T-Virus sound .
		Notes : 1- if you want to change the sound just edit the lines number : 95, 96 and make your owns, they will be triggred randomly .
			2- if you want to make only one sound just make the tow lines (95, 96) the same it means give the .wav files the same name . 
		        3- T-Sound is heard from everywhere it means every player on the server can hear it . 
			
	***** VERY IMPORTANT NOTE : IF YOU WANT TO CHANGE THE T-VIRUS COST PLEASE EDIT THE LINE NUMBER 87 AND EDIT ALSO IN THE 
				    zpa_extraitems.ini FILE *****
				    
	""""""""""""""""""""""""""""" onother note : This plugin works only in ZPA """"""""""""""""""""""""""""""""

	
	
	~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
	~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
	
	
		
	---------------
	 *||CREDITS||*
	---------------
	abdul-rehman =====> His TUT (how to create custom mode) helped me on how to declare sounds and call them .and of course for his zpa mode. 
	
	
	jc980        =====> T-Virus Sound  
	
	
	MeRcyLeZZ    =====> Original Zombie Plague mode 
	
	
		
	~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
					HAVE FUN ... 
	~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
	 : 			
	
================================================================================*/

#include <amxmodx>
#include <zombie_plague_advance>


// Item IDs
new g_t_virus, g_t_nemesis, g_t_swarm, g_t_plague, g_t_assassin, g_t_before, g_t_sound
new g_virus
// T-Virus Cost : if you want to change the price of the T-Virus please edit here and edit in the zpa_extraitems.ini also .
new const item_cost = 15
// T-Virus Name 
new const item_name[] = "T-Virus" 
// players name 
new name[32] 
// T-Virus Sound : if you want to change the T-Virus Sound just edit here . 
new const g_play_sounds[][] =
{
    "zombie_plague/T-Virus.wav" ,
    "zombie_plague/T-Virus2.wav"
}

public plugin_precache	( )
{
new i 
for (i = 0; i < sizeof g_play_sounds; i++)
        precache_sound( g_play_sounds[i] )
}

public plugin_init()
{
	register_plugin("[ZP] Extra Item : T-Virus", "1.0", "A.Madjid")
	
	// Register the new items and store their IDs for future reference
	g_virus = zp_register_extra_item(item_name, item_cost, ZP_TEAM_HUMAN) // Humans only	
	g_t_virus = register_cvar("T-Virus", "1") // on/off the pluing .
	g_t_nemesis = register_cvar("T-Nemesis", "0") // enable or desable T-Virus in nemesis mode .
	g_t_swarm = register_cvar("T-Swarm", "0") // in sawrm mode .
	g_t_plague = register_cvar("T-plague", "0") // in plague mode .
	g_t_assassin = register_cvar("T-Assassin", "0") // in assassin mode .
	g_t_before = register_cvar("T-Allow_Virus_Before_Infection_Spread", "0") // Allow T-Virus before infection starts .
	g_t_sound = register_cvar("T-Sound", "1" ) // T-Virus sound . 
	
	
}

// Item Selected forward
public zp_extra_item_selected(player, itemid)
{
	//some vars 
	new count_human = zp_get_human_count() 
	new count_zombie = zp_get_zombie_count()  
	new mode = zp_get_current_mode() 
	new ammo = zp_get_user_ammo_packs(player)
	get_user_name(player, name, 31)
	
	// Check if the selected item matches any of our registered ones
	if ( (get_pcvar_num(g_t_virus) == 1)  && (itemid == g_virus) ) 
		 {
		 	if ( (count_human > 1) && (count_zombie > 0) ) 
			{
				if (mode == MODE_NEMESIS )  
				{ 
				if ( get_pcvar_num(g_t_nemesis ) == 1 ) 
				{
					if (get_pcvar_num(g_t_sound) == 1 ) 
					{
					set_hudmessage(0, 200, 0, -0.95, 0.5, 1, 0.0, 10.0, 1.0, 1.0, -1)
					show_hudmessage(0, "%s Has Bought T-Virus !!!", name)
					client_print(player, print_chat, "[ZP] You have purchased the T-Virus!")
					zp_infect_user (player, 0, 1, 0) 
					client_cmd(0, "spk ^"%s^"", g_play_sounds[ random_num(0, sizeof g_play_sounds -1) ] )
					}
					else if (get_pcvar_num(g_t_sound) == 0 )
					{ 
					set_hudmessage(0, 200, 0, -0.95, 0.5, 1, 0.0, 10.0, 1.0, 1.0, -1)
					show_hudmessage(0, "%s Has Bought T-Virus !!!", name)
					client_print(player, print_chat, "[ZP] You have purchased the T-Virus!")
					zp_infect_user (player, 0, 1, 0) 
					}
				} 
				else  if ( get_pcvar_num(g_t_nemesis ) == 0 )
				{
				zp_set_user_ammo_packs(player,ammo + item_cost) 
				client_print(player, print_chat, "[ZP] T-Virus is disabled in this mode")
				}
				return; 
				} 
				if (mode == MODE_SWARM ) 
				{ 
				if (get_pcvar_num(g_t_swarm) == 1 )
				{
				if (get_pcvar_num(g_t_sound) == 1 ) 
					{
					set_hudmessage(0, 200, 0, -0.95, 0.5, 1, 0.0, 10.0, 1.0, 1.0, -1)
					show_hudmessage(0, "%s Has Bought T-Virus !!!", name)
					client_print(player, print_chat, "[ZP] You have purchased the T-Virus!")
					zp_infect_user (player, 0, 1, 0) 
					client_cmd(0, "spk ^"%s^"", g_play_sounds[ random_num(0, sizeof g_play_sounds -1) ] )
					}
					else if (get_pcvar_num(g_t_sound) == 0 )
					{ 
					set_hudmessage(0, 200, 0, -0.95, 0.5, 1, 0.0, 10.0, 1.0, 1.0, -1)
					show_hudmessage(0, "%s Has Bought T-Virus !!!", name)
					client_print(player, print_chat, "[ZP] You have purchased the T-Virus!")
					zp_infect_user (player, 0, 1, 0) 
					}
				} 
				else  if (get_pcvar_num(g_t_swarm) == 0 )
				{
				zp_set_user_ammo_packs(player,ammo + item_cost) 
				client_print(player, print_chat, "[ZP] T-Virus is disabled in this mode")
				} 
				return; 
				} 	 
				if (mode == MODE_PLAGUE ) 
				{ 
				if (get_pcvar_num(g_t_plague) == 1) 
				{
				if (get_pcvar_num(g_t_sound) == 1 ) 
					{
					set_hudmessage(0, 200, 0, -0.95, 0.5, 1, 0.0, 10.0, 1.0, 1.0, -1)
					show_hudmessage(0, "%s Has Bought T-Virus !!!", name)
					client_print(player, print_chat, "[ZP] You have purchased the T-Virus!")
					zp_infect_user (player, 0, 1, 0) 
					client_cmd(0, "spk ^"%s^"", g_play_sounds[ random_num(0, sizeof g_play_sounds -1) ] )
					}
					else if (get_pcvar_num(g_t_sound) == 0 )
					{ 
					set_hudmessage(0, 200, 0, -0.95, 0.5, 1, 0.0, 10.0, 1.0, 1.0, -1)
					show_hudmessage(0, "%s Has Bought T-Virus !!!", name)
					client_print(player, print_chat, "[ZP] You have purchased the T-Virus!")
					zp_infect_user (player, 0, 1, 0) 
					}
				} 
				else  if (get_pcvar_num(g_t_plague) == 0)
				{
				zp_set_user_ammo_packs(player,ammo + item_cost) 
				client_print(player, print_chat, "[ZP] T-Virus is disabled in this mode")
				} 
				return; 
				}
				if (mode == MODE_ASSASSIN) 
				{ 
				if (get_pcvar_num(g_t_assassin) == 1) 
				{
				if (get_pcvar_num(g_t_sound) == 1 ) 
					{
					set_hudmessage(0, 200, 0, -0.95, 0.5, 1, 0.0, 10.0, 1.0, 1.0, -1)
					show_hudmessage(0, "%s Has Bought T-Virus !!!", name)
					client_print(player, print_chat, "[ZP] You have purchased the T-Virus!")
					zp_infect_user (player, 0, 1, 0) 
					client_cmd(0, "spk ^"%s^"", g_play_sounds[ random_num(0, sizeof g_play_sounds -1) ] )
					}
					else if (get_pcvar_num(g_t_sound) == 0 )
					{ 
					set_hudmessage(0, 200, 0, -0.95, 0.5, 1, 0.0, 10.0, 1.0, 1.0, -1)
					show_hudmessage(0, "%s Has Bought T-Virus !!!", name)
					client_print(player, print_chat, "[ZP] You have purchased the T-Virus!")
					zp_infect_user (player, 0, 1, 0) 
					}
				} 
				else  if (get_pcvar_num(g_t_assassin) == 0) 
				{
				zp_set_user_ammo_packs(player, ammo + item_cost) 
				client_print(player, print_chat, "[ZP] T-Virus is disabled in this mode")
				} 
				return; 
				}
				else 
				{
				if (get_pcvar_num(g_t_sound) == 1 ) 
					{
					set_hudmessage(0, 200, 0, -0.95, 0.5, 1, 0.0, 10.0, 1.0, 1.0, -1)
					show_hudmessage(0, "%s Has Bought T-Virus !!!", name)
					client_print(player, print_chat, "[ZP] You have purchased the T-Virus!")
					zp_infect_user (player, 0, 1, 0) 
					client_cmd(0, "spk ^"%s^"", g_play_sounds[ random_num(0, sizeof g_play_sounds -1) ] )
					}
					else if (get_pcvar_num(g_t_sound) == 0 )
					{ 
					set_hudmessage(0, 200, 0, -0.95, 0.5, 1, 0.0, 10.0, 1.0, 1.0, -1)
					show_hudmessage(0, "%s Has Bought T-Virus !!!", name)
					client_print(player, print_chat, "[ZP] You have purchased the T-Virus!")
					zp_infect_user (player, 0, 1, 0) 
					}
				} 	
			} 
			else if ( count_human == 1 ) 
				{
				zp_set_user_ammo_packs(player, ammo + item_cost) 
				client_print(player, print_chat, "[ZP] You can't buy the T-Virus becuse you are the last human")
				}
			else if ( (!count_zombie ) && (get_pcvar_num(g_t_before) == 1) )
					{ 
						if (get_pcvar_num(g_t_sound) == 1 ) 
						{
						set_hudmessage(0, 200, 0, -0.95, 0.5, 1, 0.0, 10.0, 1.0, 1.0, -1)
						show_hudmessage(0, "%s Has Bought T-Virus !!!", name)
						client_print(player, print_chat, "[ZP] You have purchased the T-Virus!")
						zp_infect_user (player, 0, 1, 0) 
						client_cmd(0, "spk ^"%s^"", g_play_sounds[ random_num(0, sizeof g_play_sounds -1) ] )
						}
						else if (get_pcvar_num(g_t_sound) == 0 )
						{ 
						set_hudmessage(0, 200, 0, -0.95, 0.5, 1, 0.0, 10.0, 1.0, 1.0, -1)
						show_hudmessage(0, "%s Has Bought T-Virus !!!", name)
						client_print(player, print_chat, "[ZP] You have purchased the T-Virus!")
						zp_infect_user (player, 0, 1, 0) 
						}
					} 
			else if ( (!count_zombie ) && (get_pcvar_num(g_t_before) == 0) ) 	
				{
				zp_set_user_ammo_packs(player, ammo + item_cost) 
				client_print(player, print_chat, "[ZP] You can't buy the T-Virus before any GameMode start")
				}
			}
		
		else  
		{
		zp_set_user_ammo_packs(player, ammo + item_cost)
		} 
	}

	
