/**********************
amx_advanced_weaprest.sma by MagicShot ...*...
 
Usage:
amx_weaprest "weaponname" or "Weapon Group ex. submachineguns" - Refer to Readme for More Examples
 
Main Cvars:
amx_weaponrest < - Enable/Diable Avanced Weapon Restion - Deafult Enabled
amx_weaponwait < - Wait Till Next Round Before Restictions Start - Default Enabled
 
Voting Cvars:
amx_weapvote_ratio <- Vote Ratio - Default 51%
amx_wvote_delay    <- Weapon Vote delay - Default 180 Seconds
amx_xtra_wep_msg   <- Extra Weapon Messgae-  Default 0 - OFF
 
***********
*Change.Log
***********
Version 0.33 ([MUPPETS] Gonzo)
1) found another vote-bug
2) removed hardcoded pathes - using log_amx
3) Should now be approvable <!-- s:) --><img src=\"{SMILIES_PATH}/icon_e_smile.gif\" alt=\":)\" title=\"mosoly\" /><!-- s:) -->
 
Version 0.32 (by [MUPPETS] Gonzo)
1) voting fixed
2) fixed amxmodx path (still hardcoded)
 
Version 0.31
1). Bug fixes. Should now work with CS 1.6 
 
Updates:
1). CZ Testing Currently
2). Adding Sheild Restriction
3). Menu & Better Voting System to Come.
4). Cool Punishment (Ideas Requested)
 
Version 0.3
 
1). Added amx_weaponwait cvar
2). Added Group Restrictions
3). Added Inital Voting System
4). Omtimized Restriction Checking
 
Credits: Bailopan, _KaszpiR_, & Ludwig Van
**********************/
#include <amxmodx> 
#include <amxmisc> 
 
new const weaponname[31][] = {"pistols", "p228", "shotguns", "scout", "submachineguns", "auto", "zoomed", "mac10", "aug", "scoped", "elites", "fiveseven", "ump45", "sgsniper", "zoomscope", "rifles", "usp", "glock", "awp", "mp5", "para", "pump", "colt", "tmp", "g3sniper", "25", "deagle", "sg552", "ak47", "knife", "p90"}
new const vote_weapon[31][] = {"vote_pistols", "vote_p228", "vote_shotguns", "vote_scout", "vote_submachineguns", "vote_auto", "vote_zoomed", "vote_mac10", "vote_aug", "vote_scoped", "vote_elites", "vote_fiveseven", "vote_ump45", "vote_sgsniper", "vote_zoomscope", "vote_rifles", "vote_usp", "vote_glock", "vote_awp", "vote_mp5", "vote_para", "vote_pump", "vote_colt", "vote_tmp", "vote_g3sniper", "25", "vote_deagle", "vote_sg552", "vote_ak47", "vote_knife", "vote_p90"}
new pistols[31]
new shotguns[31]
new submachineguns[31]
new zoomed[31]
new scoped[31]
new zoomscope[31]
new rifles[31]
new pistols_disabled[31]
new shotguns_disabled[31]
new submachineguns_disabled[31]
new zoomed_disabled[31]
new scoped_disabled[31]
new zoomscope_disabled[31]
new rifles_disabled[31]
new weap_disabled[64]
new weap_pend[32]
new curweap
new bool:first_time[32]
new voteweapon[32]
new votewepi
new votewepi2
new voteoutcome
new votenumber = 0
new votecontroller[33][2]
new option[4]
new Float:vote_ratio
new totalvoters = 0
new bool:bVoteToStop = false
new st_vote
new bool:wvote_deny = false
 
public checkweap(id,level,cid) { 
	//if (!cmd_access(id,level,cid,3)) {
	//  client_print(id,print_console,"[AMXX] Access Check")
	//	return PLUGIN_HANDLED
	//}
	client_print(id,print_console,"[AMXX] Access Granted")
	new weap[32]
	read_argv(1,weap,31) 
	if (equal(weap,""))
		return PLUGIN_CONTINUE
 	for(new i = 0; i < 31; i++) {
		if (containi(weaponname[i], weap)!=-1)
			curweap = i
		if (first_time[i] == true)
			first_time[i] = false
	}	
	if ( (weap_disabled[curweap] == 0) && (weap_pend[curweap] != 1) ){
		if (get_cvar_num("amx_weaponwait") == 0)
			weap_disabled[curweap] = 1
 
		if (containi(weaponname[curweap], "pistols")!=-1) {
			weap_pend[0] = 1
			if (get_cvar_num("amx_weaponwait") == 1) {
				pistols[1] = 1; pistols[10] = 1; pistols[11] = 1; pistols[16] = 1; pistols[17] = 1; pistols[26] = 1; weap_pend[0] = 1
			}else {
				pistols[1] = 1; pistols[10] = 1; pistols[11] = 1; pistols[16] = 1; pistols[17] = 1; pistols[26] = 1
				pistols_disabled[1] = 1; pistols_disabled[10] = 1; pistols_disabled[11] = 1; pistols_disabled[16] = 1; pistols_disabled[17] = 1; pistols_disabled[26] = 1
			}
		}
		if (containi(weaponname[curweap], "shotguns")!=-1) {
			weap_pend[2] = 1
			if (get_cvar_num("amx_weaponwait") == 1) {
				shotguns[5] = 1; shotguns[21] = 1
			}else {
				shotguns[5] = 1; shotguns[21] = 1
				shotguns_disabled[5] = 1; shotguns_disabled[21] = 1
			}
		}
		if (containi(weaponname[curweap], "submachineguns")!=-1) {
			weap_pend[4] = 1
			if (get_cvar_num("amx_weaponwait") == 1) {
				submachineguns[7] = 1; submachineguns[12] = 1; submachineguns[19] = 1; submachineguns[23] = 1
			}else {
				submachineguns[7] = 1; submachineguns[12] = 1; submachineguns[19] = 1; submachineguns[23] = 1
				submachineguns_disabled[7] = 1; submachineguns_disabled[12] = 1; submachineguns_disabled[19] = 1; submachineguns_disabled[23] = 1
			}
		}
		if (containi(weaponname[curweap], "zoomed")!=-1) {
			weap_pend[6] = 1
			if (get_cvar_num("amx_weaponwait") == 1) {
				zoomed[8] = 1; zoomed[27] = 1
			}else {
				zoomed[8] = 1; zoomed[27] = 1
				zoomed_disabled[8] = 1; zoomed_disabled[27] = 1
			}
		}
		if (containi(weaponname[curweap], "scoped")!=-1) {
			weap_pend[9] = 1
			if (get_cvar_num("amx_weaponwait") == 1) {
				scoped[3] = 1; scoped[13] = 1; scoped[18] = 1; scoped[24] = 1
			}else {
				scoped[3] = 1; scoped[13] = 1; scoped[18] = 1; scoped[24] = 1
				scoped_disabled[3] = 1; scoped_disabled[13] = 1; scoped_disabled[18] = 1; scoped_disabled[24] = 1
			}
		}
		if (containi(weaponname[curweap], "zoomscope")!=-1) {
			weap_pend[14] = 1
			if (get_cvar_num("amx_weaponwait") == 1) {
				zoomscope[3] = 1; zoomscope[8] = 1; zoomscope[13] = 1; zoomscope[18] = 1; zoomscope[24] = 1; zoomscope[27] = 1
			}else {
				zoomscope[3] = 1; zoomscope[8] = 1; zoomscope[13] = 1; zoomscope[18] = 1; zoomscope[24] = 1; zoomscope[27] = 1
				zoomscope_disabled[3] = 1; zoomscope_disabled[8] = 1; zoomscope_disabled[13] = 1; zoomscope_disabled[18] = 1; zoomscope_disabled[24] = 1; zoomscope_disabled[27] = 1
			}
		}
		if (containi(weaponname[curweap], "rifles")!=-1) {
			weap_pend[15] = 1
			if (get_cvar_num("amx_weaponwait") == 1) {
				rifles[22] = 1; rifles[28] = 1; rifles[3] = 1; rifles[8] = 1; rifles[13] = 1; rifles[18] = 1; rifles[24] = 1; rifles[27] = 1
			}else {
				rifles[22] = 1; rifles[28] = 1; rifles[3] = 1; rifles[8] = 1; rifles[13] = 1; rifles[18] = 1; rifles[24] = 1; rifles[27] = 1
				rifles_disabled[22] = 1; rifles_disabled[28] = 1; rifles_disabled[3] = 1; rifles_disabled[8] = 1; rifles_disabled[13] = 1; rifles_disabled[18] = 1; rifles_disabled[24] = 1; rifles_disabled[27] = 1
			}
		}
		first_time[curweap] = true
		weap_pend[curweap] = 1
		client_print(id,print_console,"[AMXX] Disable %s Next Round", weaponname[curweap])
 
	}else { 
		if (containi(weaponname[curweap], "pistols")!=-1) {
			weap_pend[0] = 2
			if (get_cvar_num("amx_weaponwait") == 1) {
				pistols[1] = 2; pistols[10] = 2; pistols[11] = 2; pistols[16] = 2; pistols[17] = 2; pistols[26] = 2
			}else {
				pistols[1] = 2; pistols[10] = 2; pistols[11] = 2; pistols[16] = 2; pistols[17] = 2; pistols[26] = 2
				pistols_disabled[1] = 2; pistols_disabled[10] = 2; pistols_disabled[11] = 2; pistols_disabled[16] = 2; pistols_disabled[17] = 2; pistols_disabled[26] = 2
			}
		}
		if (containi(weaponname[curweap], "shotguns")!=-1) {
			weap_pend[2] = 2
			if (get_cvar_num("amx_weaponwait") == 1) {
				shotguns[5] = 2; shotguns[21] = 2
			}else {
				shotguns[5] = 2; shotguns[21] = 2
				shotguns_disabled[5] = 2; shotguns_disabled[21] = 2
			}
		}
		if (containi(weaponname[curweap], "submachineguns")!=-1) {
			weap_pend[4] = 2
			if (get_cvar_num("amx_weaponwait") == 1) {
				submachineguns[7] = 2; submachineguns[12] = 2; submachineguns[19] = 2; submachineguns[23] = 2
			}else {
				submachineguns[7] = 2; submachineguns[12] = 2; submachineguns[19] = 2; submachineguns[23] = 2
				submachineguns_disabled[7] = 2; submachineguns_disabled[12] = 2; submachineguns_disabled[19] = 2; submachineguns_disabled[23] = 2
			}
		}
		if (containi(weaponname[curweap], "zoomed")!=-1) {
			weap_pend[6] = 2
			if (get_cvar_num("amx_weaponwait") == 1) {
				zoomed[8] = 2; zoomed[27] = 2
			}else {
				zoomed[8] = 2; zoomed[27] = 2
				zoomed_disabled[8] = 2; zoomed_disabled[27] = 2
			}
		}
		if (containi(weaponname[curweap], "scoped")!=-1) {
			weap_pend[9] = 2
			if (get_cvar_num("amx_weaponwait") == 1) {
				scoped[3] = 2; scoped[13] = 2; scoped[18] = 2; scoped[24] = 2
			}else {
				scoped[3] = 2; scoped[13] = 1; scoped[18] = 2; scoped[24] = 2
				scoped_disabled[3] = 2; scoped_disabled[13] = 2; scoped_disabled[18] = 2; scoped_disabled[24] = 2
			}
		}
		if (containi(weaponname[curweap], "zoomscope")!=-1) {
			weap_pend[14] = 2
			if (get_cvar_num("amx_weaponwait") == 1) {
				zoomscope[3] = 2; zoomscope[8] = 2; zoomscope[13] = 2; zoomscope[18] = 2; zoomscope[24] = 2; zoomscope[27] = 2
			}else {
				zoomscope[3] = 2; zoomscope[8] = 2; zoomscope[13] = 2; zoomscope[18] = 2; zoomscope[24] = 2; zoomscope[27] = 2
				zoomscope_disabled[3] = 2; zoomscope_disabled[8] = 2; zoomscope_disabled[13] = 2; zoomscope_disabled[18] = 2; zoomscope_disabled[24] = 2; zoomscope_disabled[27] = 2
			}
		}
		if (containi(weaponname[curweap], "rifles")!=-1) {
			weap_pend[15] = 2
			if (get_cvar_num("amx_weaponwait") == 1) {
				rifles[22] = 2; rifles[28] = 2; rifles[3] = 2; rifles[8] = 2; rifles[13] = 2; rifles[18] = 2; rifles[24] = 2; rifles[27] = 2
			}else {
				rifles[22] = 2; rifles[28] = 2; rifles[3] = 2; rifles[8] = 2; rifles[13] = 2; rifles[18] = 2; rifles[24] = 2; rifles[27] = 2
				rifles_disabled[22] = 2; rifles_disabled[28] = 2; rifles_disabled[3] = 2; rifles_disabled[8] = 2; rifles_disabled[13] = 2; rifles_disabled[18] = 2; rifles_disabled[24] = 2; rifles_disabled[27] = 2
			}
		}
		weap_pend[curweap] = 2
		client_print(id,print_console,"[AMXX] Enable %s Next Round", weaponname[curweap])
		if (get_cvar_num("amx_weaponwait") == 0)
			weap_disabled[curweap] = 0
	} 
	return PLUGIN_HANDLED 
} 
 
public dropthatweapon(id) {
	if (get_cvar_num("amx_weaponrest") == 0)
		return PLUGIN_HANDLED
	new weapon, ammo, wep
	weapon = get_user_weapon(id,wep,ammo)
	new const wepi = read_data(2)
	if (get_cvar_num("amx_weaponwait") == 1) {
		if (pistols[wepi] == 1 || shotguns[wepi] == 1 || submachineguns[wepi] == 1 || zoomed[wepi] == 1|| scoped[wepi] == 1 || zoomscope[wepi] == 1 || rifles[wepi] == 1) {
			if (pistols_disabled[wepi] == 0 && shotguns_disabled[wepi] == 0 && submachineguns_disabled[wepi] == 0 && zoomed_disabled[wepi] == 0&& scoped_disabled[wepi] == 0 && zoomscope_disabled[wepi] == 0 && rifles_disabled[wepi] == 0) {
				return PLUGIN_HANDLED
			}
		}
		if (pistols[wepi] == 2 || shotguns[wepi] == 2 || submachineguns[wepi] == 2 || zoomed[wepi] == 2|| scoped[wepi] == 2 || zoomscope[wepi] == 2 || rifles[wepi] == 2) {
			if (pistols_disabled[wepi] == 0 && shotguns_disabled[wepi] == 0 && submachineguns_disabled[wepi] == 0 && zoomed_disabled[wepi] == 0 && scoped_disabled[wepi] == 0 && zoomscope_disabled[wepi] == 0 && rifles_disabled[wepi] == 0) {
				return PLUGIN_HANDLED
			}
		}else if ( (weap_disabled[wepi] == 0) && (first_time[wepi] == true) ) {
			return PLUGIN_HANDLED
		}
	}
	if ( (weap_disabled[wepi] == 0) && (weap_pend[wepi] == 0) && (pistols[wepi] == 0) && (shotguns[wepi] == 0) && (submachineguns[wepi] == 0) && (zoomed[wepi] == 0) && (scoped[wepi] == 0) && (zoomscope[wepi] == 0) && (rifles[wepi] == 0) ) {
		return PLUGIN_HANDLED
	}
	if (get_cvar_num("amx_weaponwait") == 0) {
		check_special(id,weapon,wepi)
		if (weap_pend[wepi] == 1) {
			client_print(id,print_chat,"[AMXX]  Hey butterfingers!  Dont waste your time and money. That Weapon is Disabled")
			disarm_player(id,weapon)
			return PLUGIN_HANDLED
		}
	}
	if (pistols_disabled[wepi] == 1 || shotguns_disabled[wepi] == 1 || submachineguns_disabled[wepi] == 1 || zoomed_disabled[wepi] == 1 || scoped_disabled[wepi] == 1 || zoomscope_disabled[wepi] == 1 || rifles_disabled[wepi] == 1 ) {
		check_special(id,weapon,wepi)
	}
 
	if ( (weap_disabled[wepi] == 1) && (first_time[wepi] == false) ) {
		client_print(id,print_chat,"[AMXX]  Hey butterfingers!  Dont waste your time and money. That Weapon is Disabled")
		disarm_player(id,weapon)
	}
	return PLUGIN_HANDLED
}
 
public check_special(id,weapon,wepi) {
	if (pistols_disabled[wepi] == 1) {
		client_print(id,print_chat,"[AMXX]  Hey butterfingers!  Dont waste your time and money. All Pistols Are Diabled")
		disarm_player(id,weapon)
	}
	if (shotguns_disabled[wepi] == 1) {
		client_print(id,print_chat,"[AMXX]  Hey butterfingers!  Dont waste your time and money. All Shotguns Are Diabled")
		disarm_player(id,weapon)
	}
	if (submachineguns_disabled[wepi] == 1) {
		client_print(id,print_chat,"[AMXX]  Hey butterfingers!  Dont waste your time and money. All Sub Machine Guns Are Diabled")
		disarm_player(id,weapon)
	}
	if (zoomed_disabled[wepi] == 1) {
		client_print(id,print_chat,"[AMXX]  Hey butterfingers!  Dont waste your time and money. All Zoomed Rifles Are Diabled")
		disarm_player(id,weapon)
	}
	if (scoped_disabled[wepi] == 1) {
		client_print(id,print_chat,"[AMXX]  Hey butterfingers!  Dont waste your time and money. All Scoped Rifles Are Diabled")
		disarm_player(id,weapon)
	}
	if (zoomscope_disabled[wepi] == 1) {
		client_print(id,print_chat,"[AMXX]  Hey butterfingers!  Dont waste your time and money. All Zoomed & Scoped Rifles Are Diabled")
		disarm_player(id,weapon)
	}
	if (rifles_disabled[wepi] == 1) {
		client_print(id,print_chat,"[AMXX]  Hey butterfingers!  Dont waste your time and money. All Rifles Are Diabled")
		disarm_player(id,weapon)
	}
	return PLUGIN_CONTINUE
}
 
disarm_player(victim, weapon){
	new wpname[32]
	new parm[2]
	parm[0]=victim
	get_weaponname(weapon,wpname,31)
	engclient_cmd(victim,"drop",wpname)
	return PLUGIN_CONTINUE
}
 
public WEAPVote(id,level,cid) {
	if (get_cvar_num("amx_weaponrest") == 0)
		return PLUGIN_HANDLED
	read_argv(1,voteweapon,31)
	new m = 0
	new bool:test = false
	while (++m <= 30) {
		if (equali(vote_weapon[m], voteweapon) )  {
			votewepi = m
			set_cvar_num("amx_vote_temp",m)
			test = true			
		}
	}
	if (test == false) {
		return PLUGIN_CONTINUE
	}
	if( (wvote_deny == true) && (!(get_user_flags(id)&ADMIN_MAP)) ){
		client_print(id,print_chat,"[AMXX] We just had a weapon vote. Wait a little longer.")
		return PLUGIN_HANDLED
	}
	new Float:voting = get_cvar_float("amx_last_voting")
	if (voting > get_gametime()){
		client_print(id,print_chat,"There is already one voting...")
		return PLUGIN_HANDLED
	}
	if (voting && voting + get_cvar_float("amx_vote_delay") > get_gametime()) {
		client_print(id,print_chat,"Voting not allowed at this time")
		return PLUGIN_HANDLED
	}
	new inprogress[32]
	get_cvar_string("amx_vote_inprogress",inprogress,32)
	if (equal(inprogress, "0")) {
		new keys
		new menu_msg[256]
		if ( (weap_disabled[votewepi] == 1) || (weap_pend[votewepi] == 1) ) {
			format(menu_msg,256, "\yEnable the weapon %s? \w^n^n1. Yes^n2. No", weaponname[votewepi])
			voteoutcome = 1
 
		}else {
			format(menu_msg,256, "\yDisable the weapon %s? \w^n^n1. Yes^n2. No", weaponname[votewepi])
			voteoutcome = 2
		}
		keys = (1<<0)|(1<<1)
		new authid[32],name[32]
		get_user_authid(id,authid,31)
		get_user_name(id,name,32)
		log_amx("^"%s<%d><%s><>^" vote weaponname[%s] ",name,get_user_userid(id),authid, weaponname[votewepi])
		new Float:vote_time = get_cvar_float("amx_vote_time") + 2.0
		set_cvar_float("amx_last_voting",  get_gametime() + vote_time )
		vote_ratio = get_cvar_float("amx_weapvote_ratio")
		for(new a = 0; a < 33; a++) {
			votecontroller[a][1] = 0
		}	
		votenumber++
		set_cvar_string("amx_vote_inprogress","1")
		bVoteToStop = true
		totalvoters = 0
		new Team[33]
		new maxpl = get_maxplayers()+1
		for(new k = 1; k < maxpl; k++){
			get_user_team(k,Team,33)
			if(!((equali(Team,"UNAS",4)) || (equali(Team,"SPEC",4)) || (get_user_time(k)== 0) )) {
				show_menu(k,keys,menu_msg,floatround(vote_time))
				totalvoters++
			}
		}
		st_vote = 0
		set_task(vote_time,"HandleWEAPVote")
		client_print(id,print_chat,"[AMXX] Voting has started...")
		for(new j = 0; j < 4;++j) option[j] = 0
	}else{
		client_print(id,print_chat,"[AMXX] Voting not allowed yet.")
	}
	return PLUGIN_HANDLED
}
 
public HandleWEAPVote(id) {
	votewepi2 = get_cvar_num("amx_vote_temp")
	wvote_deny = true
	set_task(get_cvar_float("amx_wvote_delay"),"wep_vote_deny")
	set_cvar_string("amx_vote_inprogress","0")
	bVoteToStop = false
	for(new a = 0; a < 33; a++){
		votecontroller[a][1] = 0
	}
	if(st_vote == 1){
		st_vote = 0
		client_print(0,print_chat,"[AMXX]  Voting sucessfully stopped.")
		return PLUGIN_HANDLED
	}
	new best = 0
	new best_count = 0
	for(new a = 0; a < 4; ++a) {
		if (option[a] > best_count){
			best_count = option[a]
			best = a
		}
	}
	new inum = totalvoters
	new Float:result_v = inum ? (float(option[best]) / float(inum)) : 0.0
	if (result_v >= vote_ratio) {
		if(best == 0){
			if (voteoutcome == 0) {
				show_hudmessage(0,"Voting Results: %s restrictions will stay^n^n%d votes to keep the %s disabled^n%d votes to enable the %s^n^n%d Total eligible voters",vote_weapon[votewepi],option[0],vote_weapon[votewepi],option[1],vote_weapon[votewepi],totalvoters)
			}else if (voteoutcome == 1) {
				show_hudmessage(0,"Voting Results: The %s will be enabled next round^n^n%d votes to keep the %s disabled^n%d votes to enable the %s^n^n%d Total eligible voters",vote_weapon[votewepi],option[0],vote_weapon[votewepi],option[1],vote_weapon[votewepi],totalvoters)
				weap_pend[votewepi2] = 2
				first_time[votewepi2] = true
			}else {
				show_hudmessage(0,"Voting Results: %s restrictions are in effect next round^n^n%d votes to disable the %s^n%d votes to keep the %s^n^n%d Total eligible voters",vote_weapon[votewepi],option[0],vote_weapon[votewepi],option[1],vote_weapon[votewepi],totalvoters)
				client_print(id, print_console, "SetVoteWepi=^"%s^"",votewepi2)
				weap_pend[votewepi2] = 1
				first_time[votewepi2] = true
			}
			log_amx("World triggered ^"voting_success^" (needed ^"%.2f^") (ratio ^"%.2f^") (result ^"%s^")",
				vote_ratio,result_v,vote_weapon[votewepi])
		}else {
			if(weap_disabled[votewepi2] == 1) {
				show_hudmessage(0,"Voting Results: The %s will be enabled next round^n^n%d votes to keep the %s disabled^n%d votes to enable the %s^n^n%d Total eligible voters",vote_weapon[votewepi],option[0],vote_weapon[votewepi],option[1],vote_weapon[votewepi],totalvoters)
				weap_pend[votewepi2] = 2
				first_time[votewepi2] = true
			} else {
				show_hudmessage(0,"Voting Results: The %s will continue to be enabled^n^n%d votes to disable the %s^n%d votes to keep the %s enabled^n^n%d Total eligible voters",vote_weapon[votewepi],option[0],vote_weapon[votewepi],option[1],vote_weapon[votewepi],totalvoters)
			}
			log_amx("World triggered ^"voting_failure^" (needed ^"%.2f^") (ratio ^"%.2f^")",vote_ratio,result_v)
		}
	}else{
		client_print(0,print_chat,"[AMXX] Voting for %s restrictions failed... No clear majority.",vote_weapon[votewepi])
	}
	return PLUGIN_HANDLED
}
 
public client_connect(id){
	votecontroller[id][1] = 0
	return PLUGIN_CONTINUE
}
 
public client_disconnect(id){
	votecontroller[id][1] = 0
	return PLUGIN_CONTINUE
}
 
public wep_vote_deny(){
	wvote_deny = false
	return PLUGIN_CONTINUE
}
 
public stopvote(id){
	if (!(get_user_flags(id)&ADMIN_MAP)){
		client_print(id,print_console,"[AMXX] You have no access to that command")
		return PLUGIN_HANDLED
	}
	if(bVoteToStop == true){
		new name[32]
		get_user_name(id,name,32)
		st_vote = 1
		client_print(id,print_console,"[AMXX]  ADMIN !!! Ignore the unknown command message -- its ok")
		client_print(0,print_chat,"[AMXX]  %s has disabled the vote in progress.",name)
	}
	return PLUGIN_CONTINUE
}
 
public vote_count(id,key){
	new name[32]
	get_user_name(id,name,32)
	if(votenumber != votecontroller[id][0]) {
		votecontroller[id][0] = votenumber
		if (get_cvar_float("amx_vote_answers")) {
			client_print(0,print_chat,"[AMXX] %s voted for option # %d",name,key+1)
		}
		option[key] += 1
	}else{
			votecontroller[id][1] +=1
		}
	return PLUGIN_CONTINUE
}
 
public round_start(id){
	if (get_cvar_num("amx_weaponrest") == 0)
		return PLUGIN_HANDLED
	delayed_rs(id)
	return PLUGIN_CONTINUE
}
 
public delayed_rs(id){
	if (get_cvar_num("amx_weaponrest") == 0)
		return PLUGIN_HANDLED
	for(new j = 0; j<31;j++) {
		if ((weap_pend[j] == 2) && (weap_disabled[j] == 1)) {
			if (weap_pend[0] == 2) {
				pistols[1] = 0; pistols[10] = 0; pistols[11] = 0; pistols[16] = 0; pistols[17] = 0; pistols[26] = 0
				pistols_disabled[1] = 0; pistols_disabled[10] = 0; pistols_disabled[11] = 0; pistols_disabled[16] = 0; pistols_disabled[17] = 0; pistols_disabled[26] = 0
			}
			if (weap_pend[2] == 2) {
				shotguns[5] = 0; shotguns[21] = 0
				shotguns_disabled[5] = 0; shotguns_disabled[21] = 0
			}
			if (weap_pend[4] == 2) {
				submachineguns[7] = 0; submachineguns[12] = 0; submachineguns[19] = 0; submachineguns[23] = 0
				submachineguns_disabled[7] = 0; submachineguns_disabled[12] = 0; submachineguns_disabled[19] = 0; submachineguns_disabled[23] = 0
			}
			if (weap_pend[6] == 2) {
				zoomed[8] = 0; zoomed[27] = 0
				zoomed_disabled[8] = 0; zoomed_disabled[27] = 0
			}
			if (weap_pend[9] == 2) {
				scoped[3] = 0; scoped[13] = 0; scoped[18] = 0; scoped[24] = 0
				scoped_disabled[3] = 0; scoped_disabled[13] = 0; scoped_disabled[18] = 0; scoped_disabled[24] = 0
			}
			if (weap_pend[14] == 2) {
				zoomscope[3] = 0; zoomscope[8] = 0; zoomscope[13] = 0; zoomscope[18] = 0; zoomscope[24] = 0; zoomscope[27] = 0
				zoomscope_disabled[3] = 0; zoomscope_disabled[8] = 0; zoomscope_disabled[13] = 0; zoomscope_disabled[18] = 0; zoomscope_disabled[24] = 0; zoomscope_disabled[27] = 0
			}
			if (weap_pend[15] == 2) {
				rifles[22] = 0; rifles[28] = 0; rifles[3] = 0; rifles[8] = 0; rifles[13] = 0; rifles[18] = 0; rifles[24] = 0; rifles[27] = 0
				rifles_disabled[22] = 0; rifles_disabled[28] = 0; rifles_disabled[3] = 0; rifles_disabled[8] = 0; rifles_disabled[13] = 0; rifles_disabled[18] = 0; rifles_disabled[24] = 0; rifles_disabled[27] = 0
			}
			weap_pend[j] = 0
			weap_disabled[j] = 0
		}
		if (weap_pend[j] == 1) {
			if (weap_pend[0] == 1) {
				pistols[1] = 1; pistols[10] = 1; pistols[11] = 1; pistols[16] = 1; pistols[17] = 1; pistols[26] = 1
				pistols_disabled[1] = 1; pistols_disabled[10] = 1; pistols_disabled[11] = 1; pistols_disabled[16] = 1; pistols_disabled[17] = 1; pistols_disabled[26] = 1
			}
			if (weap_pend[2] == 1) {
				shotguns[5] = 1; shotguns[21] = 1
				shotguns_disabled[5] = 1; shotguns_disabled[21] = 1
			}
			if (weap_pend[4] == 1) {
				submachineguns[7] = 1; submachineguns[12] = 1; submachineguns[19] = 1; submachineguns[23] = 1
				submachineguns_disabled[7] = 1; submachineguns_disabled[12] = 1; submachineguns_disabled[19] = 1; submachineguns_disabled[23] = 1
			}
			if (weap_pend[6] == 1) {
				zoomed[8] = 1; zoomed[27] = 1
				zoomed_disabled[8] = 1; zoomed_disabled[27] = 1
			}
			if (weap_pend[9] == 1) {
				scoped[3] = 1; scoped[13] = 1; scoped[18] = 1; scoped[24] = 1
				scoped_disabled[3] = 1; scoped_disabled[13] = 1; scoped_disabled[18] = 1; scoped_disabled[24] = 1
			}
			if (weap_pend[14] == 1) {
				zoomscope[3] = 1; zoomscope[8] = 1; zoomscope[13] = 1; zoomscope[18] = 1; zoomscope[24] = 1; zoomscope[27] = 1
				zoomscope_disabled[3] = 1; zoomscope_disabled[8] = 1; zoomscope_disabled[13] = 1; zoomscope_disabled[18] = 1; zoomscope_disabled[24] = 1; zoomscope_disabled[27] = 1
			}
			if (weap_pend[15] == 1) {
				rifles[22] = 1; rifles[28] = 1; rifles[3] = 1; rifles[8] = 1; rifles[13] = 1; rifles[18] = 1; rifles[24] = 1; rifles[27] = 1
				rifles_disabled[22] = 1; rifles_disabled[28] = 1; rifles_disabled[3] = 1; rifles_disabled[8] = 1; rifles_disabled[13] = 1; rifles_disabled[18] = 1; rifles_disabled[24] = 1; rifles_disabled[27] = 1
			}
			weap_disabled[j] = 1
			weap_pend[j] = 0 
		}
		if (first_time[j] == true) {
			first_time[j] = false
		}
	}
	return PLUGIN_CONTINUE
}
 
public plugin_init() { 
	register_plugin("Advanced Weapon Vote and Restriction","0.33","MagicShot") 
	register_clcmd("amx_weaprest","checkweap",ADMIN_LEVEL_A,"amx_weaprest : toggles restricted weapons eg. amx_weaprest weaponname") 
	register_event("CurWeapon","dropthatweapon","b","1=1")
	register_event("ResetHUD","round_start","b","1=1")
	register_clcmd("say", "WEAPVote")
	register_menucmd(register_menuid("Disable the"),(1<<0)|(1<<1)|(1<<2)|(1<<3),"vote_count")
	register_menucmd(register_menuid("Enable the"),(1<<0)|(1<<1)|(1<<2)|(1<<3),"vote_count")
	register_cvar("amx_weaponrest","1",0)
	register_cvar("amx_weaponwait","1",0)
	register_cvar("amx_weapvote_ratio","0.51")
	register_cvar("amx_vote_temp","0")
	register_cvar("amx_xtra_wep_msg","0")
	register_cvar("amx_map_wep_msg","0")
	register_cvar("amx_vote_inprogress","0")
	register_cvar("amx_wvote_delay","180.0")
	register_cvar("amx_last_voting","0")
	set_cvar_float("amx_last_voting",0.0)
	return PLUGIN_CONTINUE
}