
   /* AMX Mod script.
   *
   * Pistols Only
   *
   * amx_pistols 1 - restricts weapons to pistols
   *                         0 - enables all weapons
   *
   * NOTE: Plugin adminvote from AMX 0.9.x required!!!
   */
   #include <amxmod>
   #include <amxmisc>
   new bool:PistolsEnabled
   new option[2]
   public amx_enablepistols(id,level,cid) {
       if (!cmd_access(id,level,cid,1))
           return PLUGIN_HANDLED
       new arg1[4]
       read_argv(1,arg1,3)

       if (equal(arg1,"1")||equali(arg1,"on")){
           PistolsEnabled = true
           unpause("b","switchweapon")
       }
       else if (equal(arg1,"0")||equali(arg1,"off")){
           PistolsEnabled = false
           pause("b","switchweapon")
       }
       else {
           console_print(id,"Pistols  Only  Mode  is %s",PistolsEnabled ?
   "enabled" : "disabled")
           return PLUGIN_HANDLED
       }
       console_print(id,"Pistols Only Mode %s",PistolsEnabled ? "enabled"
   : "disabled")
       client_print(0,print_center,"Pistols    Only    Mode    Has   Been
   %s!",PistolsEnabled ? "Enabled" : "Disabled")

       new ppl[32], inum
       get_players(ppl,inum,"a")
       for(new a = 0; a < inum; ++a)
           switchtoprimary(ppl[a])

       set_hudmessage(0,  100,  0,  0.05, 0.65, 2, 0.02, 10.0, 0.01, 0.1,
   2)
       show_hudmessage(0,PistolsEnabled  ?  "Pistols Only Allowed" : "All
   Guns Allowed" )
       return PLUGIN_HANDLED
   }
   new primary = (1<<1)|(1<<10)|(1<<11)|(1<<16)|(1<<17)|(1<<26)|(1<<29)
   switchtoprimary(id){
       new weapons[32], inum
       get_user_weapons(id,weapons,inum)
       for(new a = 0; a < inum; ++a){
           if ( primary & (1 << weapons[a] ) ){
               new weaponname[32]
               get_weaponname(weapons[a],weaponname,31)
               engclient_cmd(id,weaponname)
               return
           }
       }
       engclient_cmd(id,"weapon_knife")
   }
   public switchweapon(id){
       if ( primary & ( 1 << read_data(2) ) )
           return PLUGIN_HANDLED /* this is pistol so return */
       switchtoprimary(id)
       return PLUGIN_HANDLED
   }
   new votepistols[] = "\yAMX %s Pistols Only Mode?\w^n^n1. Yes^n2. No"
   public vote_pistols(id){
       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 menu_msg[256]
       format(menu_msg,255,votepistols,PistolsEnabled   ?   "Disable"   :
   "Enable")
       new Float:vote_time = get_cvar_float("amx_vote_time") + 2.0
       set_cvar_float("amx_last_voting",  get_gametime() + vote_time )
       show_menu(0,(1<<0)|(1<<1),menu_msg,floatround(vote_time))
       set_task(vote_time,"check_votes")
       client_print(0,print_chat,"* Voting has started...")
       option[0]=option[1]=0
       return PLUGIN_HANDLED
   }
   public vote_count(id,key){
       if ( get_cvar_float("amx_vote_answers") ) {
           new name[32]
           get_user_name(id,name,31)
           client_print(0,print_chat,"*   %s   voted  %s",  name,  key  ?
   "against" : "for" )
       }
       ++option[key]
       return PLUGIN_HANDLED
   }
   public check_votes(id){
       if (option[0] > option[1]){
           server_cmd(  "amx_pistols %s", PistolsEnabled ? "off" : "on" )
           client_print(0,print_chat,"*  Voting  successful  (yes ^"%d^")
   (no ^"%d^").",option[0],option[1])
       }
       else{
           client_print(0,print_chat,"*  Voting  failed  (yes ^"%d^") (no
   ^"%d^").",option[0],option[1])
       }
       return PLUGIN_CONTINUE
   }
   public plugin_init() {
       register_plugin("Pistols Only","0.9","SDE")
       register_event("CurWeapon","switchweapon","be","1=1")
       register_concmd("amx_pistols","amx_enablepistols",ADMIN_LEVEL_B,"<
   1|0> - pistols only mode")
       register_clcmd("say /votepistols","vote_pistols",0,"- start voting
   session for pistols only mode")
       register_menucmd(register_menuid("Pistols                     Only
   Mode?"),(1<<0)|(1<<1),"vote_count")
       pause("b","switchweapon")
       return PLUGIN_CONTINUE
   }
