/***************************************************************************
 *  amx_ejl_weapon_restrict.sma
 *   version 3.5b       (2/12/03) Date: 12/24/2002
 *   Author: Eric Lidman     ejlmozart@hotmail.com
 *   Alias: Ludwig van       Upgrade: http://lidmanmusic.com/cs/plugins.html
 *
 *  A fun weapon restriction plugin that prevents players from buying*,
 *   using, even holding restricted guns. Weapons restrictions only take
 *   effect or are removed at round start. If an admin or vote commands a
 *   restriction, it takes effect at the beginning of the next round. There 
 *   is ample warning to players that restrictions are in place. Updated:
 *   *If you have OLO's weapon_restrict plugin installed, my weapon restrict
 *   plugin you have here will set proper buying restrictions for all the
 *   weapon modes this plugin has by commanding OLO's plugin to do so. No
 *   sense re-inventing the wheel I figure. So if you dont have that plugin,
 *   go get it and install it too. Its not necessary to the functioning of
 *   this plugin, but it does make it better. New: Cvars added to customize
 *   amout of weapon restrict messaging. See below.
 *
 *  Public comamnds:
 *
 *    say:  vote_awp         -- start a vote to disable the awp
 *    say:  vote_pistols     -- start a vote to go into pistols only mode
 *    say:  vote_scopes      -- start a vote to disable all scoped rifles
 *    say:  vote_rifles      -- start a vote to disable all rifles
 *
 *  Admin Commands:
 *
 *    amx_pistols    -- toggles on and off pistols only mode
 *    amx_awp        -- toggles on and off AWP disabled mode
 *    amx_scopes     -- toggles on and off scoped rifle restriction
 *    amx_rifles     -- toggles on and off all rifle restriction
 *    amx_shotty     -- toggles on and off pump shotguns only mode
 *    amx_autoshotty -- toggles on and off auto shotguns only mode
 *    amx_ump45      -- toggles on and off ump45 only mode
 *    amx_knifea     -- knife arena
 *    amx_gunvote    -- toggles on/off ability for players to start votes
 *                      the default setting is on
 *    amx_gunvote_default    -- sets the current gunvote value as server
 *                              default auto-refreshed at every map change
 *                              ADMIN_RCON required to set server default
 *    amx_restrict_override  -- ADMIN_RCON required - override default 
 *                              restrictions you set before and lock out
 *                              lower admins from changing them 
 *
 *  With the addition of the shotguns/ump45 only modes (activated by 
 *   an admin only) you may want that admin to have access to the 
 *   weapon give plugin so as to insure that everyone has a proper gun
 *   even if they cannot afford it. The new amx_money would work too.          
 *  There is an option for setting the default gun restrictions on a 
 *   particular map. These restrictions can be set so that regular admins
 *   cannot alter them if you wish. You need to make a text file called
 *   gun_restrictions.txt and put it in your ../addons/amx folder. The
 *   contents are in 3 parts, one map per line. The first parameter is a 
 *   number 1 or 0 to determine whether these restrictions override a non-
 *   RCON admin's command. 1 = override, 0= the restriction can be changed 
 *   by an ADMIN_LEVEL_H admin. The second pareter is the type of restriction
 *   for the map. The current options are NO_RIFLES, NO_SCOPES, NO_AWPS, 
 *   PISTOLS, KNIVES. The last parameter is the map name. Please note that if
 *   you do not create this file, one will be created for you with some 
 *   minimal default restrictions already in place. Change then as you wish.
 *   For more info on setup, see the example below:  
 *      Format: <override admins 0|1 > <type of restriction> <mapname>
 *
 *      1 NO_RIFLES  he_offroad
 *      1 PISTOLS    oc_bestjump3
 *      0 NO_SCOPES  cs_funpark
 *      1 NO_AWPS    cs_jeep_rally2
 *
 *  Cvars:
 *
 *	amx_xtra_wep_msg 0    -- default is 0 to have the hudmessage only. Set 
 *                             to 1 in your admin.cfg to send both a hudmessage
 *                             and a line in the chat warning of restrictions at
 *                             the beginning of each round. 
 *	amx_map_wep_msg 0     -- default is 0 to hot show any weapon restriction
 *                             messages at the beginning of each round when 
 *                             restrictions are made for a map from the
 *                             gun_restrictions.txt file. Set to 1 if you want
 *                             to show the messages for this case.   
 *
 *  Original credit: Thanks, without your lead, I might not have written this.
 *   Original Plugin "Knife Arena" by  tcquest78
 *   Modified to be the "Pistols Only" plugin by:  SDE: sde@ocsclan.com
 *   Modified and built into this plugin by Ludwig van
 * 
 ****************************************************************************/
#include <amxmod>
#include <amxmisc>
new vault_value[128]
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:bGunvote = true
new restrict_override = 0
new PistolsEnabled
new AWPDisabled
new KnifeEnabled
new SCOPEDisabled
new RIFLEDisabled
new ShottyOnly
new aShottyOnly
new umpOnly
new bool:wvote_deny = false
new bool:first_time = false
new bool:map_rest = false
new MsgControl
new pist_pend
new awp_pend
new scope_pend
new rif_pend
new shotty_pend
new ashotty_pend
new ump_pend

public amx_enablepistols(id,level,cid) {
	if (!cmd_access(id,level,cid,1))
		return PLUGIN_HANDLED
	if (restrict_override == 1) {
		console_print(id,"[AMX] Override is on. Weapons restrictions cannot be changed.")
		return PLUGIN_HANDLED 
	}
	first_time = true
	map_rest = false
	set_hudmessage(0, 100, 0, -1.0, 0.65, 2, 0.02, 10.0, 0.01, 0.1, 2) 
	if(PistolsEnabled == 0) {
		pist_pend = 1
		awp_pend = 0
		scope_pend = 0
		rif_pend = 0
		shotty_pend = 0
		ashotty_pend = 0
		ump_pend = 0
		show_hudmessage(0,"Pistols Only Enabled starting next round.")
		client_print(0,print_center,"Pistols Only Mode Has Been Enabled starting next round")
		console_print(id,"[AMX] Pistols Only Mode now in effect starting next round") 
	}else {
		show_hudmessage(0,"All Guns Enabled starting next round")
		client_print(0,print_center,"Pistols Only Mode Has Been Disabled starting next round") 
		console_print(id,"[AMX] All weapons now enabled starting next round")
		pist_pend = 2
		awp_pend = 0
		scope_pend = 0
		rif_pend = 0
		shotty_pend = 0
		ashotty_pend = 0
		ump_pend = 0
	}   
	return PLUGIN_HANDLED
} 

public amx_disableawp(id,level,cid) {
	if (!cmd_access(id,level,cid,1))
		return PLUGIN_HANDLED
	if (restrict_override == 1) {
		console_print(id,"[AMX] Override is on. Weapons restrictions cannot be changed.")
		return PLUGIN_HANDLED 
	}
	first_time = true
	map_rest = false
	set_hudmessage(0, 100, 0, -1.0, 0.65, 2, 0.02, 10.0, 0.01, 0.1, 2) 
  	if(AWPDisabled == 0) {
		pist_pend = 0
		awp_pend = 1
		scope_pend = 0
		rif_pend = 0
		shotty_pend = 0
		ashotty_pend = 0
		ump_pend = 0
		show_hudmessage(0,"AWP is Disabled starting next round")
		client_print(0,print_center,"AWP is Disabled starting next round") 
		console_print(id,"[AMX] Set AWP Disabled Mode starting next round")
	}else {
		show_hudmessage(0,"All Guns Enabled starting next round")
		client_print(0,print_center,"AWP is Enabled starting next round") 
		console_print(id,"[AMX] All weapons enabled starting next round")
		pist_pend = 0
		awp_pend = 2
		scope_pend = 0
		rif_pend = 0
		shotty_pend = 0
		ashotty_pend = 0
		ump_pend = 0 
	}
	return PLUGIN_HANDLED
} 

public amx_noscope(id,level,cid) {
	if (!cmd_access(id,level,cid,1))
		return PLUGIN_HANDLED
	if (restrict_override == 1) {
		console_print(id,"[AMX] Override is on. Weapons restrictions cannot be changed.")
		return PLUGIN_HANDLED 
	}
	map_rest = false
	first_time = true
	set_hudmessage(0, 100, 0, -1.0, 0.65, 2, 0.02, 10.0, 0.01, 0.1, 2) 
	if(SCOPEDisabled == 0) {
		pist_pend = 0
		awp_pend = 0
		scope_pend = 1
		rif_pend = 0
		shotty_pend = 0
		ashotty_pend = 0
		ump_pend = 0
		show_hudmessage(0,"Scoped rifles are Disabled starting next round.")
		client_print(0,print_center,"ALL Scope rifles are disabled starting next round") 
		console_print(id,"[AMX] Set SCOPE RILFE Disabled Mode starting next round")
	}else {
		show_hudmessage(0,"All Guns Enabled starting next round")
		client_print(0,print_center,"Scope rifles are Enabled starting next round") 
		console_print(id,"[AMX] All weapons enabled starting next round")
		pist_pend = 0
		awp_pend = 0
		scope_pend = 2
		rif_pend = 0
		shotty_pend = 0
		ashotty_pend = 0
		ump_pend = 0 
	}
	return PLUGIN_HANDLED
} 

public amx_norifle(id,level,cid) {
	if (!cmd_access(id,level,cid,1))
		return PLUGIN_HANDLED
	if (restrict_override == 1) {
		console_print(id,"[AMX] Override is on. Weapons restrictions cannot be changed.")
		return PLUGIN_HANDLED 
	}
	map_rest = false
	first_time = true
	set_hudmessage(0, 100, 0, -1.0, 0.65, 2, 0.02, 10.0, 0.01, 0.1, 2)  
   	if(RIFLEDisabled == 0) {
		pist_pend = 0
		awp_pend = 0
		scope_pend = 0
		rif_pend = 1
		shotty_pend = 0
		ashotty_pend = 0
		ump_pend = 0
		show_hudmessage(0,"RILFES are Disabled starting next round")
		client_print(0,print_center,"ALL rifles are disabled starting next round") 
		console_print(id,"[AMX] Set RILFE Disabled Mode starting next round")
	}else {
		show_hudmessage(0,"All Guns Enabled starting next round")
		client_print(0,print_center,"Rifles are Enabled starting next round") 
		console_print(id,"[AMX] All weapons enabled starting next round") 
		pist_pend = 0
		awp_pend = 0
		scope_pend = 0
		rif_pend = 2
		shotty_pend = 0
		ashotty_pend = 0
		ump_pend = 0 
	}
	return PLUGIN_HANDLED
} 

public amx_shotty(id,level,cid) {
	if (!cmd_access(id,level,cid,1))
		return PLUGIN_HANDLED
	if (restrict_override == 1) {
		console_print(id,"[AMX] Override is on. Weapons restrictions cannot be changed.")
		return PLUGIN_HANDLED 
	}
	map_rest = false
	first_time = true
	set_hudmessage(0, 100, 0, -1.0, 0.65, 2, 0.02, 10.0, 0.01, 0.1, 2)  
	if(ShottyOnly == 0) {
		pist_pend = 0
		awp_pend = 0
		scope_pend = 0
		rif_pend = 0
		shotty_pend = 1
		ashotty_pend = 0
		ump_pend = 0
		show_hudmessage(0,"Shotguns Only Enabled starting next round")
		client_print(0,print_center,"Shotguns Only Mode Has Been Enabled starting next round")
		console_print(id,"[AMX] Shotguns Only Mode in effect starting next round") 
	}else {
		show_hudmessage(0,"All Guns Enabled starting next round")
		client_print(0,print_center,"Shotguns Only Mode Has Been Disabled starting next round") 
		console_print(id,"[AMX] All weapons enabled starting next round")
		pist_pend = 0
		awp_pend = 0
		scope_pend = 0
		rif_pend = 0
		shotty_pend = 2
		ashotty_pend = 0
		ump_pend = 0  
	}   
	return PLUGIN_HANDLED
}

public amx_ashotty(id,level,cid) {
	if (!cmd_access(id,level,cid,1))
		return PLUGIN_HANDLED
	if (restrict_override == 1) {
		console_print(id,"[AMX] Override is on. Weapons restrictions cannot be changed.")
		return PLUGIN_HANDLED 
	}
	map_rest = false
	first_time = true
	set_hudmessage(0, 100, 0, -1.0, 0.65, 2, 0.02, 10.0, 0.01, 0.1, 2)   
	if(aShottyOnly == 0) {
		pist_pend = 0
		awp_pend = 0
		scope_pend = 0
		rif_pend = 0
		shotty_pend = 0
		ashotty_pend = 1
		ump_pend = 0
		show_hudmessage(0,"Auto Shotguns Only Enabled starting next round")
		client_print(0,print_center,"Auto Shotguns Only Mode Has Been Enabled starting next round")
		console_print(id,"[AMX] Auto Shotguns Only Mode in effect starting next round") 
	}else {
		show_hudmessage(0,"All Guns Enabled starting next round")
		client_print(0,print_center,"Auto Shotguns Only Mode Has Been Disabled starting next round") 
		console_print(id,"[AMX] All weapons enabled starting next round")
		pist_pend = 0
		awp_pend = 0
		scope_pend = 0
		rif_pend = 0
		shotty_pend = 0
		ashotty_pend = 2
		ump_pend = 0 
	}   
	return PLUGIN_HANDLED
} 

public amx_ump45Only(id,level,cid) {
	if (!cmd_access(id,level,cid,1))
		return PLUGIN_HANDLED
	if (restrict_override == 1) {
		console_print(id,"[AMX] Override is on. Weapons restrictions cannot be changed.")
		return PLUGIN_HANDLED 
	}
	map_rest = false
	first_time = true
	set_hudmessage(0, 100, 0, -1.0, 0.65, 2, 0.02, 10.0, 0.01, 0.1, 2)  
	if(umpOnly == 0) {
		pist_pend = 0
		awp_pend = 0
		scope_pend = 0
		rif_pend = 0
		shotty_pend = 0
		ashotty_pend = 0
		ump_pend = 1
		show_hudmessage(0,"UMP45 Only Enabled starting next round")
		client_print(0,print_center,"UMP45 Only Mode Has Been Enabled starting next round")
		console_print(id,"[AMX] UMP45 Only Mode in effect starting next round") 
	}else {
		show_hudmessage(0,"All Guns Enabled starting next round")
		client_print(0,print_center,"UMP45 Only Mode Has Been Disabled starting next round") 
		console_print(id,"[AMX] All weapons enabled starting next round")
		pist_pend = 0
		awp_pend = 0
		scope_pend = 0
		rif_pend = 0
		shotty_pend = 0
		ashotty_pend = 0
		ump_pend = 2 
	}   
	return PLUGIN_HANDLED
}

public amx_gunvote(id,level,cid){
	if (!cmd_access(id,level,cid,1))
		return PLUGIN_HANDLED
	if(bGunvote == false) {
		bGunvote = true
		client_print(0,print_chat,"[AMX]  Admin has allowed players to initiate vote_pistols and vote_awp") 
		console_print(id,"[AMX]  You have allowed players to initiate vote_pistols and vote_awp")
	}else {
		bGunvote = false
		client_print(0,print_chat,"[AMX]  Admin has forbidden players to initiate vote_pistols and vote_awp") 
		console_print(id,"[AMX]  You have forbidden players to initiate vote_pistols and vote_awp")
	}	
	new authid[16],name[32]
	get_user_authid(id,authid,16)
	get_user_name(id,name,32)
	log_to_file("addons/amx/admin.log","^"%s<%d><%s><>^" gunvote_mode",name,get_user_userid(id),authid)
	return PLUGIN_HANDLED
}

public amx_gunvote_d(id,level,cid){
	if (!cmd_access(id,level,cid,1))
		return PLUGIN_HANDLED
	if(bGunvote == false){
		ejl_vault("WRITE","GUN_VOTE","OFF")
		console_print(id,"[AMX] Player initiated weapons voting  OFF   is now the default.")
	}else{
		ejl_vault("WRITE","GUN_VOTE","ON")
		console_print(id,"[AMX] Player initiated weapons voting  ON    is now the default.")
	}
	new authid[16],name[32]
	get_user_authid(id,authid,16)
	get_user_name(id,name,32)
	log_to_file("addons/amx/admin.log","^"%s<%d><%s><>^" gunvote_mode_d",name,get_user_userid(id),authid)
	return PLUGIN_HANDLED
}

public amx_override(id,level,cid) {
	if (!cmd_access(id,level,cid,1))
		return PLUGIN_HANDLED
	if (restrict_override == 0) {
		console_print(id,"[AMX] Override is ON.  Weapons restrictions cannot be changed.")
 		restrict_override = 1
	}else{
		console_print(id,"[AMX] Override is OFF. Weapons restrictions can now be changed.")
		restrict_override = 0
	}
	return PLUGIN_HANDLED
}

public amx_enableknife(id,level,cid) {
	if (!cmd_access(id,level,cid,1))
		return PLUGIN_HANDLED
	if (restrict_override == 1) {
		console_print(id,"[AMX] Override is on. Weapons restrictions cannot be changed.")
		return PLUGIN_HANDLED 
	}
	map_rest = false
	set_hudmessage(0, 100, 0, -1.0, 0.65, 2, 0.02, 10.0, 0.01, 0.1, 2)  
	if(KnifeEnabled == 0) {
		engclient_cmd(0,"weapon_knife")
		show_hudmessage(0,"Knife Arena!")
		client_print(0,print_center,"Knife Arena Has Been Enabled!")
		console_print(id,"[AMX] Knife Arena is now in effect")
		PistolsEnabled = 0
		AWPDisabled = 0
		SCOPEDisabled = 0
		RIFLEDisabled = 0
		aShottyOnly = 0
		ShottyOnly = 0
		umpOnly = 0
		KnifeEnabled = 1
		pist_pend = 0
		awp_pend = 0
		scope_pend = 0
		rif_pend = 0
		shotty_pend = 0
		ashotty_pend = 0
		ump_pend = 0   		
	}else {
		show_hudmessage(0,"All Guns Enabled")
		client_print(0,print_center,"Knife Arena disabled!") 
		console_print(id,"[AMX] All weapons now enabled")
		KnifeEnabled = 0
	} 
	return PLUGIN_HANDLED
}

public dropthatweapon(id) {
    if(PistolsEnabled == 1) {
        new wepi = read_data(2)
        if(wepi == 1 || wepi == 6 || wepi == 10 || wepi == 11 || wepi == 16 || wepi == 17 || wepi == 26 || wepi == 29 || wepi == 4 || wepi == 9 || wepi == 25 )
            return PLUGIN_HANDLED
        if (bGunvote == false)
            client_print(id,print_chat,"[AMX]  Hey butterfingers!  Dont waste your time and money. It's pistols only.")
        else
            client_print(id,print_chat,"[AMX]  Hey butterfingers!  Dont waste your time and money. It's pistols only now. Say: vote_pistols")
        engclient_cmd(id,"drop")
        return PLUGIN_HANDLED
    }
    else if(AWPDisabled == 1) {
        new wepi = read_data(2)
        if(wepi != 18)
            return PLUGIN_HANDLED
        if (bGunvote == false)
            client_print(id,print_chat,"[AMX]  Hey butterfingers!  Dont waste your time and money. It's no AWPs.")
        else
            client_print(id,print_chat,"[AMX]  Hey butterfingers!  Dont waste your time and money. It's no AWPs now. say: vote_awp")
        engclient_cmd(id,"drop") 
        return PLUGIN_HANDLED
    }
    else if(SCOPEDisabled == 1) {
        new wepi = read_data(2)
        if(wepi == 3 || wepi == 8 || wepi == 13 || wepi == 18 || wepi == 24 || wepi == 27){
            client_print(id,print_chat,"[AMX]  Hey butterfingers!  Dont waste your time and money. It's no scoped weapons.")
            engclient_cmd(id,"drop")
        }
        return PLUGIN_HANDLED
    }
    else if(RIFLEDisabled == 1) {
        new wepi = read_data(2)
        if(wepi == 3 || wepi == 8 || wepi == 13 || wepi == 18 || wepi == 24 || wepi == 27 || wepi == 22 || wepi == 28){
            client_print(id,print_chat,"[AMX]  Hey butterfingers!  Dont waste your time and money. It's no rifles.")
            engclient_cmd(id,"drop")
        }
        return PLUGIN_HANDLED
    }
    else if(ShottyOnly == 1) {
        new wepi = read_data(2)
        if(wepi != 6 && wepi != 21 && wepi != 29 && wepi !=4 && wepi != 9 && wepi != 25){
            client_print(id,print_chat,"[AMX]  Hey butterfingers!  Shotguns only.")
            engclient_cmd(id,"drop")
        }
        return PLUGIN_HANDLED
    }
    else if(aShottyOnly == 1) {
        new wepi = read_data(2)
        if(wepi != 6 && wepi != 5 && wepi != 29 && wepi !=4 && wepi != 9 && wepi != 25){
            client_print(id,print_chat,"[AMX]  Hey butterfingers!  Auto-Shotguns only.")
            engclient_cmd(id,"drop")
        }
        return PLUGIN_HANDLED
    }
    else if(umpOnly == 1) {
        new wepi = read_data(2)
        if(wepi != 6 && wepi != 12 && wepi != 29 && wepi !=4 && wepi != 9 && wepi != 25){
            client_print(id,print_chat,"[AMX]  Hey butterfingers!  UMP45 only.")
            engclient_cmd(id,"drop")
        }
        return PLUGIN_HANDLED
    }
    else if (KnifeEnabled == 1){
        engclient_cmd(id,"weapon_knife")
        return PLUGIN_HANDLED
    }
    return PLUGIN_HANDLED
} 

public HandleSay(id) {
	new Speech[192]
	read_args(Speech,192)
	remove_quotes(Speech)
	if (equali(Speech, "vote_pistols")) {
		if (restrict_override == 1) {
			client_print(id,print_chat,"[AMX] Weapons restrictions cannot be changed. Override is on.") 
			return PLUGIN_HANDLED
		}else{ 
			if( (bGunvote == false) && (!(get_user_flags(id)&ADMIN_MAP)) ){
				client_print(id,print_chat,"[AMX]  vote_pistols is set to be activated by admin only.")
			}else{ 				 
				PISTOLSVote(id)
			}
		}
	}
	else if (equali(Speech, "vote_awp")) {
		if (restrict_override == 1) { 
			client_print(id,print_chat,"[AMX] Weapons restrictions cannot be changed. Override is on.") 
			return PLUGIN_HANDLED
		}else{
			if( (bGunvote == false) && (!(get_user_flags(id)&ADMIN_MAP)) ){
				client_print(id,print_chat,"[AMX]  vote_awp is set to be activated by admin only.")
			}else{ 
				AWPVote(id)
			}
		}
	}
	else if (equali(Speech, "vote_scopes")) {
		if (restrict_override == 1) { 
			client_print(id,print_chat,"[AMX] Weapons restrictions cannot be changed. Override is on.") 
			return PLUGIN_HANDLED
		}else{
			if( (bGunvote == false) && (!(get_user_flags(id)&ADMIN_MAP)) ){
				client_print(id,print_chat,"[AMX]  vote_scopes is set to be activated by admin only.")
			}else{ 
				SCOPEVote(id)
			}
		}
	}
	else if (equali(Speech, "vote_rifles")) {
		if (restrict_override == 1) { 
			client_print(id,print_chat,"[AMX] Weapons restrictions cannot be changed. Override is on.") 
			return PLUGIN_HANDLED
		}else{
			if( (bGunvote == false) && (!(get_user_flags(id)&ADMIN_MAP)) ){
				client_print(id,print_chat,"[AMX]  vote_rifles is set to be activated by admin only.")
			}else{ 
				RIFLEVote(id)
			}
		}
	}
	else if( (restrict_override == 0) && (bGunvote == true) ){
		if ( (containi(Speech, "awp") != -1) || (containi(Speech, "gun") != -1) || (containi(Speech, "pistol") != -1) || (containi(Speech, "rifle") != -1) || (containi(Speech, "scope") != -1) ){
			if(PistolsEnabled == 1){
				client_print(id,print_chat, "[AMX]  Its Pistols only right now. To change say vote_pistols")
			}
			else if(AWPDisabled == 1){
				client_print(id,print_chat, "[AMX]  The AWP is disabled right now. To change say vote_awp")
			}
			else if(SCOPEDisabled == 1){
				client_print(id,print_chat, "[AMX]  Scoped rifles are disabled right now. To change say vote_scopes")
			}
			else if(RIFLEDisabled == 1){
				client_print(id,print_chat, "[AMX]  All rifles are disabled right now. To change say vote_rifles")
			}else{
				client_print(id,print_chat, "[AMX]  All weapons enabled. To change say vote_awp, vote_pistols, vote_scopes, or vote_rifles")
			}			
		}
	}
	return PLUGIN_CONTINUE
}

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,level,cid){
	if (!cmd_access(id,level,cid,1))
		return PLUGIN_HANDLED
	if(bVoteToStop == true){
		new name[32]
		get_user_name(id,name,32)
		st_vote = 1
		client_print(id,print_console,"[AMX]  ADMIN !!! Ignore the unknown command message -- its ok")
		client_print(0,print_chat,"[AMX]  %s has disabled the vote in progress.",name)
	}
	return PLUGIN_CONTINUE
}

public vote_count(id,key){
	ejl_vault("READ","CURRENT_VOTE","")
	if(equal(vault_value,"WEAPONS")){
	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,"[AMX] %s voted for option # %d",name,key+1)
		}
		option[key] += 1
	}else{
		votecontroller[id][1] +=1
	}
	}else{
		return PLUGIN_CONTINUE
	}
	return PLUGIN_HANDLED
}

public AWPVote(id) {
	if( (wvote_deny == true) && (!(get_user_flags(id)&ADMIN_MAP)) ){
		client_print(id,print_chat,"[AMX] 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",1)){
	new menu_msg[256]
	new keys
	format(menu_msg,256,"\yDisable the AWP? \w^n^n1.  Yes^n2.  No")
	keys = (1<<0)|(1<<1)
	new authid[16],name[32]
	get_user_authid(id,authid,16)
	get_user_name(id,name,32)
	log_to_file("addons/amx/admin.log","^"%s<%d><%s><>^" vote awp",name,get_user_userid(id),authid)
	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_awpvote_ratio")
	for(new a = 0; a < 33; a++){
		votecontroller[a][1] = 0
	}
	votenumber++
	set_cvar_string("amx_vote_inprogress","1")
	ejl_vault("WRITE","CURRENT_VOTE","WEAPONS")
	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(!is_user_bot(k)){
			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,"HandleAWPVote")
	client_print(id,print_chat,"[AMX] Voting has started...")
	for(new j = 0; j < 4;++j) option[j] = 0
	}else{
	client_print(id,print_chat,"[AMX] Voting not allowed yet.")	
	}
	return PLUGIN_HANDLED
}

public HandleAWPVote() {
	set_hudmessage(63,187,239, -1.0, 0.70, 2, 0.02, 10.0, 0.01, 0.1, 4)
	map_rest = false
	wvote_deny = true
	set_task(get_cvar_float("amx_wvote_delay"),"wep_vote_deny")
	set_cvar_string("amx_vote_inprogress","0")
	ejl_vault("WRITE","CURRENT_VOTE","NULL")
	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,"[AMX]  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(AWPDisabled == 1) {
 				show_hudmessage(0,"Voting Results: AWP restrictions will stay^n^n%d votes to keep the AWP disabled^n%d votes to enable the AWP^n^n%d Total eligible voters",
				option[0],option[1],totalvoters)
			} else {
 				show_hudmessage(0,"Voting Results: AWP restrictions are in effect next round^n^n%d votes to disable the AWP^n%d votes to keep the AWP^n^n%d Total eligible voters",
				option[0],option[1],totalvoters)
				pist_pend = 0
				awp_pend = 1
				scope_pend = 0
				rif_pend = 0
				shotty_pend = 0
				ashotty_pend = 0
				ump_pend = 0
				first_time = true
			}
			log_to_file("addons/amx/admin.log","World triggered ^"voting_success^" (needed ^"%.2f^") (ratio ^"%.2f^") (result ^"awp^")",
				vote_ratio,result_v)
		}else {
			if(AWPDisabled == 1) {
				show_hudmessage(0,"Voting Results: The AWP will be enabled next round^n^n%d votes to keep the AWP disabled^n%d votes to enable the AWP^n^n%d Total eligible voters",
				option[0],option[1],totalvoters)
				awp_pend = 2
				first_time = true
			} else {
 				show_hudmessage(0,"Voting Results: The AWP will continue to be enabled^n^n%d votes to disable the AWP^n%d votes to keep the AWP enabled^n^n%d Total eligible voters",
				option[0],option[1],totalvoters)
			}
			log_to_file("addons/amx/admin.log","World triggered ^"voting_failure^" (needed ^"%.2f^") (ratio ^"%.2f^")",
				vote_ratio,result_v)
		}
	}else{
		client_print(0,print_chat,"[AMX] Voting for AWP restrictions failed... No clear majority.")
	}
	return PLUGIN_HANDLED
} 

public PISTOLSVote(id) {
	if( (wvote_deny == true) && (!(get_user_flags(id)&ADMIN_MAP)) ){
		client_print(id,print_chat,"[AMX] 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",1)){
	new menu_msg[256]
	new keys
	format(menu_msg,256,"\yPistols Only? \w^n^n1.  Yes^n2.  No")
	keys = (1<<0)|(1<<1)
	new authid[16],name[32]
	get_user_authid(id,authid,16)
	get_user_name(id,name,32)
	log_to_file("addons/amx/admin.log","^"%s<%d><%s><>^" vote pistols",name,get_user_userid(id),authid)
	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_pistolsvote_ratio")
	for(new a = 0; a < 33; a++){
		votecontroller[a][1] = 0
	}
	votenumber++
	set_cvar_string("amx_vote_inprogress","1")
	ejl_vault("WRITE","CURRENT_VOTE","WEAPONS")
	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(!is_user_bot(k)){
			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,"HandlePISTOLSVote")
	client_print(id,print_chat,"[AMX] Voting has started...")
	for(new j = 0; j < 4;++j) option[j] = 0
	}else{
	client_print(id,print_chat,"[AMX] Voting not allowed yet.")	
	}
	return PLUGIN_HANDLED
}

public HandlePISTOLSVote() {
	set_hudmessage(63,187,239, -1.0, 0.70, 2, 0.02, 10.0, 0.01, 0.1, 4)
	map_rest = false
	wvote_deny = true
	set_task(get_cvar_float("amx_wvote_delay"),"wep_vote_deny")
	set_cvar_string("amx_vote_inprogress","0")
	ejl_vault("WRITE","CURRENT_VOTE","NULL")
	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,"[AMX]  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((PistolsEnabled == 1) || (pist_pend == 1)) {
 				show_hudmessage(0,"Voting Results: Pistols only will stay^n^n%d votes to keep pistols only^n%d votes to enable all weapons^n^n%d Total eligible voters",
				option[0],option[1],totalvoters)
			} else {
 				show_hudmessage(0,"Voting Results: Pistols only is in effect next round^n^n%d votes for pistols only^n%d votes to keep all weapons enabled^n^n%d Total eligible voters",
				option[0],option[1],totalvoters)
				pist_pend = 1
				awp_pend = 0
				scope_pend = 0
				rif_pend = 0
				shotty_pend = 0
				ashotty_pend = 0
				ump_pend = 0
				first_time = true
			}
			log_to_file("addons/amx/admin.log","World triggered ^"voting_success^" (needed ^"%.2f^") (ratio ^"%.2f^") (result ^"pistols^")",
				vote_ratio,result_v)
		}else {
			if(PistolsEnabled == 1) {
				show_hudmessage(0,"Voting Results: All weapons are enabled next round^n^n%d votes to keep pistols only^n%d votes to enable all weapons^n^n%d Total eligible voters",
				option[0],option[1],totalvoters)
				pist_pend = 2
				first_time = true
			} else {
 				show_hudmessage(0,"Voting Results: All weapons will continue to be enabled^n^n%d votes for pistols only^n%d votes to keep all weapons^n^n%d Total eligible voters",
				option[0],option[1],totalvoters)
			}
			log_to_file("addons/amx/admin.log","World triggered ^"voting_failure^" (needed ^"%.2f^") (ratio ^"%.2f^")",
				vote_ratio,result_v)
		}
	}else{
		client_print(0,print_chat,"[AMX] Voting for pistols only failed... No clear majority.")
	}
	return PLUGIN_HANDLED
}

public SCOPEVote(id) {
	if( (wvote_deny == true) && (!(get_user_flags(id)&ADMIN_MAP)) ){
		client_print(id,print_chat,"[AMX] 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",1)){
	new menu_msg[256]
	new keys
	format(menu_msg,256,"\yDisable all Scoped Rifles? \w^n^n1.  Yes^n2.  No")
	keys = (1<<0)|(1<<1)
	new authid[16],name[32]
	get_user_authid(id,authid,16)
	get_user_name(id,name,32)
	log_to_file("addons/amx/admin.log","^"%s<%d><%s><>^" vote scopes",name,get_user_userid(id),authid)
	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_scopevote_ratio")
	for(new a = 0; a < 33; a++){
		votecontroller[a][1] = 0
	}
	votenumber++
	set_cvar_string("amx_vote_inprogress","1")
	ejl_vault("WRITE","CURRENT_VOTE","WEAPONS")
	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(!is_user_bot(k)){
			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,"HandleSCOPEVote")
	client_print(id,print_chat,"[AMX] Voting has started...")
	for(new j = 0; j < 4;++j) option[j] = 0
	}else{
	client_print(id,print_chat,"[AMX] Voting not allowed yet.")	
	}
	return PLUGIN_HANDLED
}

public HandleSCOPEVote() {
	set_hudmessage(63,187,239, -1.0, 0.70, 2, 0.02, 10.0, 0.01, 0.1, 4)
	map_rest = false
	wvote_deny = true
	set_task(get_cvar_float("amx_wvote_delay"),"wep_vote_deny")
	set_cvar_string("amx_vote_inprogress","0")
	ejl_vault("WRITE","CURRENT_VOTE","NULL")
	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,"[AMX]  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(SCOPEDisabled == 1) {
 				show_hudmessage(0,"Voting Results: Scoped rifle restrictions will stay^n^n%d votes to keep scoped rifles disabled^n%d votes to enable scoped rifles^n^n%d Total eligible voters",
				option[0],option[1],totalvoters)
			} else {
 				show_hudmessage(0,"Voting Results: Scoped rifle restrictions are in effect next round^n^n%d votes to disable scoped rifles^n%d votes to keep scoped rifles^n^n%d Total eligible voters",
				option[0],option[1],totalvoters)
				pist_pend = 0
				awp_pend = 0
				scope_pend = 1
				rif_pend = 0
				shotty_pend = 0
				ashotty_pend = 0
				ump_pend = 0
				first_time = true
			}
			log_to_file("addons/amx/admin.log","World triggered ^"voting_success^" (needed ^"%.2f^") (ratio ^"%.2f^") (result ^"scope^")",
				vote_ratio,result_v)
		}else {
			if(SCOPEDisabled == 1) {
				show_hudmessage(0,"Voting Results: Scoped rifles will be enabled next round^n^n%d votes to keep scoped rifles disabled^n%d votes to enable scoped rifles^n^n%d Total eligible voters",
				option[0],option[1],totalvoters)
				scope_pend = 2
				first_time = true
			} else {
 				show_hudmessage(0,"Voting Results: Scoped rifles will continue to be enabled^n^n%d votes to disable scoped rifles^n%d votes to keep scoped rifles enabled^n^n%d Total eligible voters",
				option[0],option[1],totalvoters)
			}
			log_to_file("addons/amx/admin.log","World triggered ^"voting_failure^" (needed ^"%.2f^") (ratio ^"%.2f^")",
				vote_ratio,result_v)
		}
	}else{
		client_print(0,print_chat,"[AMX] Voting for scoped rifle restrictions failed... No clear majority.")
	}
	return PLUGIN_HANDLED
}

public RIFLEVote(id) {
	if( (wvote_deny == true) && (!(get_user_flags(id)&ADMIN_MAP)) ){
		client_print(id,print_chat,"[AMX] 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",1)){
	new menu_msg[256]
	new keys
	format(menu_msg,256,"\yDisable all Rifles? \w^n^n1.  Yes^n2.  No")
	keys = (1<<0)|(1<<1)
	new authid[16],name[32]
	get_user_authid(id,authid,16)
	get_user_name(id,name,32)
	log_to_file("addons/amx/admin.log","^"%s<%d><%s><>^" vote rifles",name,get_user_userid(id),authid)
	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_riflevote_ratio")
	for(new a = 0; a < 33; a++){
		votecontroller[a][1] = 0
	}
	votenumber++
	set_cvar_string("amx_vote_inprogress","1")
	ejl_vault("WRITE","CURRENT_VOTE","WEAPONS")
	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(!is_user_bot(k)){
			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,"HandleRIFLEVote")
	client_print(id,print_chat,"[AMX] Voting has started...")
	for(new j = 0; j < 4;++j) option[j] = 0
	}else{
	client_print(id,print_chat,"[AMX] Voting not allowed yet.")	
	}
	return PLUGIN_HANDLED
}

public HandleRIFLEVote() {
	set_hudmessage(63,187,239, -1.0, 0.70, 2, 0.02, 10.0, 0.01, 0.1, 4)
	map_rest = false
	wvote_deny = true
	set_task(get_cvar_float("amx_wvote_delay"),"wep_vote_deny")
	set_cvar_string("amx_vote_inprogress","0")
	ejl_vault("WRITE","CURRENT_VOTE","NULL")
	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,"[AMX]  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(RIFLEDisabled == 1) {
 				show_hudmessage(0,"Voting Results: Rifle restrictions will stay^n^n%d votes to keep rifles disabled^n%d votes to enable rifles^n^n%d Total eligible voters",
				option[0],option[1],totalvoters)
			} else {
 				show_hudmessage(0,"Voting Results: Rifle restrictions are in effect next round^n^n%d votes to disable rifles^n%d votes to keep rifles^n^n%d Total eligible voters",
				option[0],option[1],totalvoters)
				pist_pend = 0
				awp_pend = 0
				scope_pend = 0
				rif_pend = 1
				shotty_pend = 0
				ashotty_pend = 0
				ump_pend = 0
				first_time = true
			}
			log_to_file("addons/amx/admin.log","World triggered ^"voting_success^" (needed ^"%.2f^") (ratio ^"%.2f^") (result ^"rifles^")",
				vote_ratio,result_v)
		}else {
			if(RIFLEDisabled == 1) {
				show_hudmessage(0,"Voting Results: Rifles will be enabled next round^n^n%d votes to keep rifles disabled^n%d votes to enable rifles^n^n%d Total eligible voters",
				option[0],option[1],totalvoters)
				rif_pend = 2
				first_time = true
			} else {
 				show_hudmessage(0,"Voting Results: Rifles will continue to be enabled^n^n%d votes to disable rifles^n%d votes to keep rifles enabled^n^n%d Total eligible voters",
				option[0],option[1],totalvoters)
			}
			log_to_file("addons/amx/admin.log","World triggered ^"voting_failure^" (needed ^"%.2f^") (ratio ^"%.2f^")",
				vote_ratio,result_v)
		}
	}else{
		client_print(0,print_chat,"[AMX] Voting for rifle restrictions failed... No clear majority.")
	}
	return PLUGIN_HANDLED
}

public roundend_cleanup(){
	MsgControl = 0
	return PLUGIN_CONTINUE	
}

reset_restr(){
	server_cmd("amx_restrict buy")
	server_cmd("amx_restrict shotgun")
	server_cmd("amx_restrict sub")
	server_cmd("amx_restrict rifle")
	if(MsgControl == 1){	
		return PLUGIN_CONTINUE
	}
	if(awp_pend == 1 || shotty_pend == 1 || ashotty_pend == 1 || ump_pend == 1 || rif_pend == 1 || scope_pend == 1 || pist_pend == 1){
		engclient_cmd(0,"weapon_knife")	
		engclient_cmd(0,"weapon_awp")
	 	if(shotty_pend == 1 || ashotty_pend == 1 || ump_pend == 1 || rif_pend == 1 || scope_pend == 1 || pist_pend == 1){
			engclient_cmd(0,"weapon_sg552") 
			engclient_cmd(0,"weapon_aug") 
			engclient_cmd(0,"weapon_g3sg1") 
			engclient_cmd(0,"weapon_scout") 
			engclient_cmd(0,"weapon_sg550")
		 	if(shotty_pend == 1 || ashotty_pend == 1 || ump_pend == 1 || rif_pend == 1 || pist_pend == 1){
				engclient_cmd(0,"weapon_m4a1") 
				engclient_cmd(0,"weapon_ak47") 
			 	if(shotty_pend == 1){
					engclient_cmd(0,"weapon_m249") 
					engclient_cmd(0,"weapon_mp5navy") 
					engclient_cmd(0,"weapon_mac10") 
					engclient_cmd(0,"weapon_tmp") 
					engclient_cmd(0,"weapon_ump45") 
					engclient_cmd(0,"weapon_p90") 
					engclient_cmd(0,"weapon_xm1014")
				}
			 	else if(ashotty_pend == 1){
					engclient_cmd(0,"weapon_m249") 
					engclient_cmd(0,"weapon_mp5navy") 
					engclient_cmd(0,"weapon_mac10") 
					engclient_cmd(0,"weapon_tmp") 
					engclient_cmd(0,"weapon_ump45") 
					engclient_cmd(0,"weapon_p90") 
					engclient_cmd(0,"weapon_m3") 
				}	
			 	else if(ump_pend == 1){
					engclient_cmd(0,"weapon_m249") 
					engclient_cmd(0,"weapon_mp5navy") 
					engclient_cmd(0,"weapon_mac10") 
					engclient_cmd(0,"weapon_tmp") 
					engclient_cmd(0,"weapon_p90") 
					engclient_cmd(0,"weapon_m3") 
					engclient_cmd(0,"weapon_xm1014")
				}
				else if(pist_pend == 1){
					engclient_cmd(0,"weapon_m249") 
 					engclient_cmd(0,"weapon_mp5navy") 
					engclient_cmd(0,"weapon_mac10") 
					engclient_cmd(0,"weapon_tmp") 
					engclient_cmd(0,"weapon_ump45") 
					engclient_cmd(0,"weapon_p90") 
					engclient_cmd(0,"weapon_xm1014")
					engclient_cmd(0,"weapon_m3") 
				}
			}
		}
		engclient_cmd(0,"drop")
		engclient_cmd(0,"weapon_usp")
 		engclient_cmd(0,"weapon_glock18")
		engclient_cmd(0,"weapon_elite")
		engclient_cmd(0,"weapon_p228")
		engclient_cmd(0,"weapon_fiveseven")
		engclient_cmd(0,"weapon_deagle")
		engclient_cmd(0,"weapon_m4a1") 
		engclient_cmd(0,"weapon_ak47") 
		engclient_cmd(0,"weapon_sg552") 
		engclient_cmd(0,"weapon_aug") 
		engclient_cmd(0,"weapon_m249") 
		engclient_cmd(0,"weapon_g3sg1") 
		engclient_cmd(0,"weapon_scout") 
		engclient_cmd(0,"weapon_sg550")
		engclient_cmd(0,"weapon_mp5navy") 
		engclient_cmd(0,"weapon_mac10") 
		engclient_cmd(0,"weapon_tmp") 
		engclient_cmd(0,"weapon_ump45") 
		engclient_cmd(0,"weapon_p90") 
		engclient_cmd(0,"weapon_xm1014")
		engclient_cmd(0,"weapon_m3") 
 	}
	return PLUGIN_CONTINUE
}

public round_start(){
	if(pist_pend == 1){
		reset_restr()
		server_cmd("amx_restrict buy 2345")
 	}
	else if(awp_pend == 1){
		reset_restr()
		server_cmd("amx_restrict rifle 6")
	}
	else if(rif_pend == 1){
		reset_restr()
		server_cmd("amx_restrict buy 4")
	}
	else if(scope_pend == 1){
		reset_restr()
		server_cmd("amx_restrict rifle 245678")
	}
	else if(shotty_pend == 1){
		reset_restr()
		server_cmd("amx_restrict buy 1345")
		server_cmd("amx_restrict shotgun 2")
	}
	else if(ashotty_pend == 1){
		reset_restr()
		server_cmd("amx_restrict buy 1345")
		server_cmd("amx_restrict shotgun 1")
	}
	else if(ump_pend == 1){
		reset_restr()
		server_cmd("amx_restrict buy 1245")
		server_cmd("amx_restrict sub 1234678")
	}
	set_task(0.2,"delayed_rs")
	return PLUGIN_CONTINUE
}

public delayed_rs(){
	if(MsgControl == 1){	
		return PLUGIN_CONTINUE
	}
	MsgControl = 1

	if(first_time == true){
		set_hudmessage(63,187,239, -1.0, 0.47, 2, 0.02, 4.5, 0.01, 0.1, 4)
		first_time = false
	}else{
		set_hudmessage(63,187,239, -1.0, 0.73, 2, 0.02, 4.5, 0.01, 0.1, 4)
	}
	if( (pist_pend == 2) && (PistolsEnabled == 1) ){
		show_hudmessage(0,"WARNING!^nITS NO LONGER PISTOLS ONLY^nALL WEAPONS ARE ENABLED^nBUY A REAL GUN")
		client_print(0,print_chat,"[AMX] WARNING! ITS NO LONGER PISTOLS ONLY, ALL WEAPONS ARE ENABLED")
		PistolsEnabled = 0
		pist_pend = 0
		reset_restr()		
	}
	if( (awp_pend == 2) && (AWPDisabled == 1) ){
		show_hudmessage(0,"WARNING!^nITS NO LONGER DISABLED AWP^nALL WEAPONS ARE ENABLED^nSPEND THAT MONEY")
		client_print(0,print_chat,"[AMX] WARNING! ITS NO LONGER DISABLED AWP, ALL WEAPONS ARE ENABLED")
		AWPDisabled = 0
		awp_pend = 0
		reset_restr()
	}
	if( (rif_pend == 2) && (RIFLEDisabled == 1) ){
		show_hudmessage(0,"WARNING!^nITS NO LONGER DISABLED RIFLES^nALL WEAPONS ARE ENABLED^nSPEND THAT MONEY")
		client_print(0,print_chat,"[AMX] WARNING! ITS NO LONGER DISABLED RIFLES, ALL WEAPONS ARE ENABLED")
		RIFLEDisabled = 0
		rif_pend = 0
		reset_restr()
	}
	if( (scope_pend == 2) && (SCOPEDisabled == 1) ){
		show_hudmessage(0,"WARNING!^nITS NO LONGER DISABLED SCOPE RIFLES^nALL WEAPONS ARE ENABLED^nSPEND THAT MONEY")
		client_print(0,print_chat,"[AMX] WARNING! ITS NO LONGER DISABLED SCOPE RIFLES, ALL WEAPONS ARE ENABLED")
		SCOPEDisabled = 0
		scope_pend = 0
		reset_restr()
	}
	if( (shotty_pend == 2) && (ShottyOnly == 1) ){
		show_hudmessage(0,"WARNING!^nITS NO LONGER PUMP SHOTGUNS ONLY^nALL WEAPONS ARE ENABLED^nBUY A REAL GUN")
		client_print(0,print_chat,"[AMX] WARNING! ITS NO LONGER PUMP SHOTGUNS ONLY, ALL WEAPONS ARE ENABLED")
		ShottyOnly = 0
		shotty_pend = 0
		reset_restr()		
	}
	if( (ashotty_pend == 2) && (aShottyOnly == 1) ){
		show_hudmessage(0,"WARNING!^nITS NO LONGER AUTO SHOTGUNS ONLY^nALL WEAPONS ARE ENABLED^nBUY A REAL GUN")
		client_print(0,print_chat,"[AMX] WARNING! ITS NO LONGER AUTO SHOTGUNS ONLY, ALL WEAPONS ARE ENABLED")
		aShottyOnly = 0
		ashotty_pend = 0
		reset_restr()		
	}
	if( (ump_pend == 2) && (umpOnly == 1) ){
		show_hudmessage(0,"WARNING!^nITS NO LONGER UMP45 ONLY^nALL WEAPONS ARE ENABLED^nBUY A REAL GUN")
		client_print(0,print_chat,"[AMX] WARNING! ITS NO LONGER UMP45 ONLY, ALL WEAPONS ARE ENABLED")
		umpOnly = 0
		ump_pend = 0
		reset_restr()		
	}
	if(pist_pend == 1){
		PistolsEnabled = 1
		AWPDisabled = 0
		KnifeEnabled = 0 
		SCOPEDisabled = 0 
		RIFLEDisabled = 0
		ShottyOnly = 0
		aShottyOnly = 0
		umpOnly = 0
		if((get_cvar_num("amx_map_wep_msg") == 0) && (map_rest == true) ){
			return PLUGIN_CONTINUE
		}
		show_hudmessage(0,"PISTOLS ONLY^nIF YOU ATTEMPT TO PULL OUT A PRIMARY WEAPON^nOR IF YOU BUY A PRIMARY WEAPON^nYOU WILL BE FORCED TO DROP IT")
		if(get_cvar_num("amx_xtra_wep_msg") == 1){
			client_print(0,print_chat,"[AMX] PISTOLS ONLY, YOU WILL BE FORCED TO DROP ANYTHING ELSE")
		}
	}
	else if(awp_pend == 1){
		AWPDisabled = 1
		PistolsEnabled = 0
		KnifeEnabled = 0 
		SCOPEDisabled = 0
		RIFLEDisabled = 0
		ShottyOnly = 0
		aShottyOnly = 0
		umpOnly = 0
		if((get_cvar_num("amx_map_wep_msg") == 0) && (map_rest == true) ){
			return PLUGIN_CONTINUE
		}
		show_hudmessage(0,"NO AWP'S^nIF YOU ATTEMPT TO PULL OUT AN AWP^nOR IF YOU BUY AN AWP^nYOU WILL BE FORCED TO DROP IT")
		if(get_cvar_num("amx_xtra_wep_msg") == 1){
			client_print(0,print_chat,"[AMX] NO AWP'S, YOU WILL BE FORCED TO DROP THE AWP IF YOU PULL IT OUT")
		}
	}
	else if(rif_pend == 1) {
		umpOnly = 0
		ShottyOnly = 0
		aShottyOnly = 0
		SCOPEDisabled = 0
		AWPDisabled = 0
		PistolsEnabled = 0
		KnifeEnabled = 0
		RIFLEDisabled = 1
		if((get_cvar_num("amx_map_wep_msg") == 0) && (map_rest == true) ){
			return PLUGIN_CONTINUE
		}
		show_hudmessage(0,"NO RIFLES^nIF YOU ATTEMPT TO PULL OUT A RIFLE^nOR IF YOU BUY A RIFLE^nYOU WILL BE FORCED TO DROP IT")
		if(get_cvar_num("amx_xtra_wep_msg") == 1){
			client_print(0,print_chat,"[AMX] NO RIFLES, YOU WILL BE FORCED TO DROP YOUR RIFLE IF YOU PULL IT OUT")
		}
	}
	else if(scope_pend == 1){
		SCOPEDisabled = 1
		aShottyOnly = 0
		ShottyOnly = 0
		umpOnly = 0
		AWPDisabled = 0
		PistolsEnabled = 0
		KnifeEnabled = 0
		RIFLEDisabled = 0
		if((get_cvar_num("amx_map_wep_msg") == 0) && (map_rest == true) ){
			return PLUGIN_CONTINUE
		}
		show_hudmessage(0,"NO SCOPED GUNS^nIF YOU ATTEMPT TO PULL OUT A SCOPED GUN^nOR IF YOU BUY A SCOPED GUN^nYOU WILL BE FORCED TO DROP IT")
		if(get_cvar_num("amx_xtra_wep_msg") == 1){
			client_print(0,print_chat,"[AMX] NO SCOPED GUNS, YOU WILL BE FORCED TO DROP ANY SCOPED GUN YOU PULL OUT")
		}
	}
	else if(shotty_pend == 1){
		ShottyOnly = 1
		umpOnly = 0
		aShottyOnly = 0
		PistolsEnabled = 0
		AWPDisabled = 0
		KnifeEnabled = 0 
		SCOPEDisabled = 0 
		RIFLEDisabled = 0
		if((get_cvar_num("amx_map_wep_msg") == 0) && (map_rest == true) ){
			return PLUGIN_CONTINUE
		}
		show_hudmessage(0,"PUMP SHOTGUNS ONLY^nPLEASE BUY ONE OR YOUR WILL BE UNARMED^nANY OTHER GUN YOU PULL OUT NOW^nYOU WILL BE FORCED TO DROP")
		if(get_cvar_num("amx_xtra_wep_msg") == 1){
			client_print(0,print_chat,"[AMX] PUMP SHOTGUNS ONLY, BUY ONE!  YOU WILL BE FORCED TO DROP ANY OTHER GUN")
		}
	}
	else if(ashotty_pend == 1){
		aShottyOnly = 1
		ShottyOnly = 0
		umpOnly = 0
		PistolsEnabled = 0
		AWPDisabled = 0
		KnifeEnabled = 0 
		SCOPEDisabled = 0 
		RIFLEDisabled = 0
		if((get_cvar_num("amx_map_wep_msg") == 0) && (map_rest == true) ){
			return PLUGIN_CONTINUE
		}
		show_hudmessage(0,"AUTO SHOTGUNS ONLY^nPLEASE BUY ONE OR YOUR WILL BE UNARMED^nANY OTHER GUN YOU PULL OUT NOW^nYOU WILL BE FORCED TO DROP")
		if(get_cvar_num("amx_xtra_wep_msg") == 1){
			client_print(0,print_chat,"[AMX] AUTO SHOTGUNS ONLY, BUY ONE! YOU WILL BE FORCED TO DROP ANY OTHER GUN")
		}
	}
	else if(ump_pend == 1) {
		umpOnly = 1
		aShottyOnly = 0
		ShottyOnly = 0
		PistolsEnabled = 0
		AWPDisabled = 0
		KnifeEnabled = 0 
		SCOPEDisabled = 0 
		RIFLEDisabled = 0
		if((get_cvar_num("amx_map_wep_msg") == 0) && (map_rest == true) ){
			return PLUGIN_CONTINUE
		}
		show_hudmessage(0,"UMP45 ONLY^nPLEASE BUY ONE OR YOUR WILL BE UNARMED^nANY OTHER GUN YOU PULL OUT NOW^nYOU WILL BE FORCED TO DROP")
		if(get_cvar_num("amx_xtra_wep_msg") == 1){
			client_print(0,print_chat,"[AMX] UMP45 ONLY, BUY ONE! YOU WILL BE FORCED TO DROP ANY OTHER GUN")
		}
	}
	return PLUGIN_CONTINUE
}

public plugin_init() { 
	register_plugin("Weapon Vote and Restrict","3.5b","EJL") 
	register_event("CurWeapon","dropthatweapon","b","1=1")
	register_event("SendAudio","round_start","bc","2=%!MRAD_GO","2=%!MRAD_MOVEOUT","2=%!MRAD_LETSGO","2=%!MRAD_LOCKNLOAD")
	register_event("SendAudio","roundend_cleanup","a","2=%!MRAD_terwin","2=%!MRAD_ctwin","2=%!MRAD_rounddraw")
 	register_concmd("amx_pistols","amx_enablepistols",ADMIN_LEVEL_H,":  toggles pistols only mode on and off") 
	register_concmd("amx_awp","amx_disableawp",ADMIN_LEVEL_H,": toggles disabled awp mode on and off")
	register_concmd("amx_scopes","amx_noscope",ADMIN_LEVEL_H,": toggles disabled scope rifle mode on and off")
	register_concmd("amx_rifles","amx_norifle",ADMIN_LEVEL_H,": toggles disabled all rifle mode on and off")
	register_concmd("amx_shotty","amx_shotty",ADMIN_LEVEL_H,": toggles shotguns only mode on and off")
	register_concmd("amx_autoshotty","amx_ashotty",ADMIN_LEVEL_H,": toggles auto-shotguns only mode on and off")
	register_concmd("amx_ump45","amx_ump45Only",ADMIN_LEVEL_H,": toggles ump45 only mode on and off")
	register_concmd("amx_knifea","amx_enableknife",ADMIN_LEVEL_C,": toggles knives only mode on and off")
	register_concmd("amx_gunvote","amx_gunvote",ADMIN_LEVEL_H,": toggles ability for players to start gun votes on and off")
	register_concmd("amx_gunvote_default","amx_gunvote_d",ADMIN_RCON,": sets the current gunvote mode to server default")
	register_concmd("amx_restrict_override","amx_override",ADMIN_RCON,": toggles default restriction override mode on and off")
	register_concmd("stopvote","stopvote",ADMIN_MAP,"stops vote in progress")
	register_clcmd("say", "HandleSay")
	register_menucmd(register_menuid("Disable the AWP? "),(1<<0)|(1<<1)|(1<<2)|(1<<3),"vote_count")
	register_cvar("amx_awpvote_ratio","0.51")
	register_menucmd(register_menuid("Pistols Only? "),(1<<0)|(1<<1)|(1<<2)|(1<<3),"vote_count")
	register_cvar("amx_pistolsvote_ratio","0.51")
	register_menucmd(register_menuid("Disable all Rifles? "),(1<<0)|(1<<1)|(1<<2)|(1<<3),"vote_count")
	register_cvar("amx_riflevote_ratio","0.51")
	register_menucmd(register_menuid("Disable all Scoped Rifles? "),(1<<0)|(1<<1)|(1<<2)|(1<<3),"vote_count")
	register_cvar("amx_scopevote_ratio","0.51")
	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)
	new ThisMap[33]
	get_mapname(ThisMap, 33)
	if(file_exists("addons/amx/gun_restrictions.txt") == 1){
		new line = 0
		new data[128]
		new stextsize = 0
		new override[4]
		new gun[16]
		new map[32]
		while((line=read_file("addons/amx/gun_restrictions.txt",line,data,128,stextsize))!=0){
			parse(data,override,4,gun,16,map,32)
			if(equali(map,ThisMap)){
				map_rest = true
				if(equal(override,"1"))
					restrict_override = 1
				if(equali(gun,"NO_RIFLES",5)){
					rif_pend = 1
					RIFLEDisabled = 1
				}
				else if(equali(gun,"NO_SCOPES",5)){
					SCOPEDisabled = 1
					scope_pend = 1
				}
				else if(equali(gun,"NO_AWPS",5)){
					AWPDisabled = 1
					awp_pend = 1
				}
				else if(equali(gun,"PISTOLS",5)){
					PistolsEnabled = 1
					pist_pend = 1
				}
				else if(equali(gun,"KNIVES",5))
					KnifeEnabled = 1
			}
		}		
	}else{
		write_file("addons/amx/gun_restrictions.txt","*** GUN-MAP RESTRICTION FILE. SEE README. EXAMPLE BELOW:",-1)
 		write_file("addons/amx/gun_restrictions.txt","1 NO_RIFLES  he_offroad",-1)
 		write_file("addons/amx/gun_restrictions.txt","1 PISTOLS    oc_bestjump3",-1)
	}
	ejl_vault("READ","GUN_VOTE","")
	if(equal(vault_value,"OFF"))
		bGunvote = false
	else
		bGunvote = true
	ejl_vault("WRITE","CURRENT_VOTE","NULL")
	return PLUGIN_CONTINUE
}

public ejl_vault(rw[],key[],value[]){
	new data[192]
	new stxtsize = 0
	new line = 0 
	new skip = 0
	new vkey[64]
	new vvalue[128]
	new vaultwrite[192]
	if(equal(rw,"READ")){
		if(file_exists("addons/amx/ejl_vault.ini") == 1){
			copy(vault_value,128,"")
			while((line=read_file("addons/amx/ejl_vault.ini",line,data,192,stxtsize))!=0){
				parse(data,vkey,64,vvalue,128)
				if(equal(vkey,key)){
					copy(vault_value,128,vvalue)
				}
			}
		}else{
			write_file("addons/amx/ejl_vault.ini", "**** Plugins use to store values -- immune to crashes and map changes ****", 0)
		}
	}
	else if(equal(rw,"WRITE")){
		if(file_exists("addons/amx/ejl_vault.ini") == 1){		
			format(vaultwrite,192,"%s %s",key,value)
			while((line=read_file("addons/amx/ejl_vault.ini",line,data,192,stxtsize))!=0){
				parse(data,vkey,64,vvalue,128)
				if(skip == 0){
					if( (equal(data,"")) || (equal(vkey,key)) ){
						skip = 1
						write_file("addons/amx/ejl_vault.ini",vaultwrite,line-1)
					}
				}
				else if(equal(vkey,key)){
					write_file("addons/amx/ejl_vault.ini","",line-1)
				}
			}
			if(skip == 0){
				write_file("addons/amx/ejl_vault.ini",vaultwrite,-1)
			}				
		}
	}
	return PLUGIN_CONTINUE
}
