
   /* Uber Pistol Mode v1.0 - Made By AssKicR
   *
   *Usage:  Client  Command:  say  give < weapon to get > req. ADMIN_USER
   (z)
   *
   * Cvar for turning on/off Client command = sv_pistolsonly 1/0 (default
   = 1)
   *  Cvar for turning off/on Multiweapons =   sv_dropgunz 1/0 (default =
   1)
   *
   *Note: <weapon to get> you enter the buy menu numbers
   * Also note that the client does not drop his current weapon and
   * can hold more then 1 primary and secondary weapon
   *
   *
   *EXAMPLE- Getting Free berrettas : say give 15 <--- This will give the
   player who wrote it dual berrettas
   *
   * Have fun!
   *
   *Thanx  to  {W`C}  Bludy, SDE, AssKicR (myself of course) for code and
   TheCreep for giving idea
   *
   * Version History
   * V 1.0 - Creation of plugin
   */
   #include <amxmod>
   #include <amxmisc>

   public give_weapon(admin_index,victim_index,weapon_give)
   {
       new arg1[32]
       read_argv(1,arg1,32)
       new team[32]
       get_user_team(victim_index,team,32)
       new name[32]
       get_user_name(victim_index,name,32)
       if (equal(arg1,"@"))
       {
       if (equal(team,"CT"))
           {
           set_hudmessage(200, 50, 0, -1.0, 0.30, 0, 6.0, 6.0, 0.5, 0.15,
   1)
           show_hudmessage(0,"The Counter-Terrorists Have Been Given Free
   Gunz")
           }
           else if (equal(team,"TERRORIST"))
           {
           set_hudmessage(200, 50, 0, -1.0, 0.30, 0, 6.0, 6.0, 0.5, 0.15,
   1)
           show_hudmessage(0,"The Terrorists Have Been Given Free Gunz")
           }
       }
       else
       {
       set_hudmessage(200, 50, 0, -1.0, 0.30, 0, 6.0, 6.0, 0.5, 0.15, 1)
       show_hudmessage(0,"%s Has Been Given A Free Gun",name)
       }
   //Pistols
       if (weapon_give == 10){
              if (get_cvar_num("sv_dropgunz")==1) {
          client_print(victim_index,print_chat,"[AMX] You cannot get full
   menus free in single weapon mode.")

           return PLUGIN_HANDLED
           }
       give_item(victim_index,"weapon_usp")
       give_item(victim_index,"ammo_45acp")
       give_item(victim_index,"ammo_45acp")
       give_item(victim_index,"ammo_45acp")
       give_item(victim_index,"ammo_45acp")
       give_item(victim_index,"ammo_45acp")
       give_item(victim_index,"ammo_45acp")
       give_item(victim_index,"ammo_45acp")
       give_item(victim_index,"weapon_glock18")
       give_item(victim_index,"weapon_elite")
       give_item(victim_index,"ammo_9mm")
       give_item(victim_index,"ammo_9mm")
       give_item(victim_index,"ammo_9mm")
       give_item(victim_index,"ammo_9mm")
       give_item(victim_index,"weapon_deagle")
       give_item(victim_index,"ammo_50ae")
       give_item(victim_index,"ammo_50ae")
       give_item(victim_index,"ammo_50ae")
       give_item(victim_index,"ammo_50ae")
       give_item(victim_index,"ammo_50ae")
       give_item(victim_index,"weapon_p228")
       give_item(victim_index,"ammo_357sig")
       give_item(victim_index,"ammo_357sig")
       give_item(victim_index,"ammo_357sig")
       give_item(victim_index,"ammo_357sig")
       give_item(victim_index,"ammo_357sig")
       give_item(victim_index,"weapon_fiveseven")
       give_item(victim_index,"ammo_57mm")
       give_item(victim_index,"ammo_57mm")
       }
       else if (weapon_give == 11){
          if (get_cvar_num("sv_dropgunz")==1)
      {
           engclient_cmd(victim_index,"drop")
           }
       give_item(victim_index,"weapon_usp")
       give_item(victim_index,"ammo_45acp")
       give_item(victim_index,"ammo_45acp")
       give_item(victim_index,"ammo_45acp")
       give_item(victim_index,"ammo_45acp")
       give_item(victim_index,"ammo_45acp")
       give_item(victim_index,"ammo_45acp")
       give_item(victim_index,"ammo_45acp")
       }
       else if (weapon_give == 12){
          if (get_cvar_num("sv_dropgunz")==1)
      {
           engclient_cmd(victim_index,"drop")
           }
       give_item(victim_index,"weapon_glock18")
       give_item(victim_index,"ammo_9mm")
       give_item(victim_index,"ammo_9mm")
       give_item(victim_index,"ammo_9mm")
       give_item(victim_index,"ammo_9mm")
       }
       else if (weapon_give == 13){
          if (get_cvar_num("sv_dropgunz")==1)
      {
           engclient_cmd(victim_index,"drop")
           }
       give_item(victim_index,"weapon_deagle")
       give_item(victim_index,"ammo_50ae")
       give_item(victim_index,"ammo_50ae")
       give_item(victim_index,"ammo_50ae")
       give_item(victim_index,"ammo_50ae")
       give_item(victim_index,"ammo_50ae")
       }
       else if (weapon_give == 14){
          if (get_cvar_num("sv_dropgunz")==1)
      {
           engclient_cmd(victim_index,"drop")
           }
       give_item(victim_index,"weapon_p228")
       give_item(victim_index,"ammo_357sig")
       give_item(victim_index,"ammo_357sig")
       give_item(victim_index,"ammo_357sig")
       give_item(victim_index,"ammo_357sig")
       }
       else if (weapon_give == 15){
          if (get_cvar_num("sv_dropgunz")==1)
      {
           engclient_cmd(victim_index,"drop")
           }
       give_item(victim_index,"weapon_elite")
       give_item(victim_index,"ammo_9mm")
       give_item(victim_index,"ammo_9mm")
       give_item(victim_index,"ammo_9mm")
       give_item(victim_index,"ammo_9mm")
       }
       else if (weapon_give == 16){
          if (get_cvar_num("sv_dropgunz")==1)
      {
           engclient_cmd(victim_index,"drop")
           }
       give_item(victim_index,"weapon_fiveseven")
       give_item(victim_index,"ammo_57mm")
       give_item(victim_index,"ammo_57mm")
       }
       else
       {
       client_print(admin_index,print_console,"[AMX]  There  is  no  such
   weapon")
       client_print(admin_index,print_chat,"[AMX]   There   is   no  such
   weapon")
       return PLUGIN_CONTINUE
       }

       return PLUGIN_CONTINUE
   }
   public handle_say(id)
   {
   //Give me a free gun now
       new said[31]
       new cmd[9]
       new key[22]

       read_args(said, 30)
       replace(said, 30, "^"", "")
       parse(said, cmd,8, key,21)
   if (equal(cmd, "give", 8)) {
      if (id) {
                 if (get_cvar_num("sv_pistolsonly")==0) {
                 client_print(id,print_chat,"[AMX]  Getting  free weapons
   is disabled by admin")
                 return PLUGIN_HANDLED
                                 }
                 else
                   {
                   give_weapon(id,id,str_to_num(key))
                   return PLUGIN_CONTINUE
                           }
                       }
                   }
                   return PLUGIN_CONTINUE
               }
   public plugin_init()
   {
       register_plugin("Uber Pistol Mode","1.0","AssKicR")
       register_clcmd("say","handle_say",ADMIN_USER,"say   give   <Weapon
   buycode>.")
       register_cvar("sv_pistolsonly","1",0)
       register_cvar("sv_dropgunz","1",0)
       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
   }
   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")
       set_cvar_num("sv_pistolsonly",1)
      }
      else if (equal(arg1,"0")||equali(arg1,"off")){
       PistolsEnabled = false
       pause("b","switchweapon")
       set_cvar_num("sv_pistolsonly",0)
      }
      else {
         console_print(id,"Uber   Pistol  Mode  is  %s",PistolsEnabled  ?
   "enabled" : "disabled")
         return PLUGIN_HANDLED
      }
      console_print(id,"Uber Pistol Mode %s",PistolsEnabled ? "enabled" :
   "disabled")
      client_print(0,print_center,"Uber     Pistol    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  ? "say give <1X> to get a pistol"
   : "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) ) ) {
       getammo(id)
       return PLUGIN_HANDLED /* this is pistol so return */
       }
      else {
      switchtoprimary(id)
      return PLUGIN_HANDLED
      }
      return PLUGIN_CONTINUE
   }
   public getammo(id){
       new  clip, ammo
       new wpn_id=get_user_weapon(id, clip, ammo);
       new wpn[32]
       if   (   wpn_id==CSW_C4  ||  wpn_id==CSW_HEGRENADE  ||  wpn_id  ==
   CSW_SMOKEGRENADE  ||  wpn_id == CSW_FLASHBANG || wpn_id == CSW_KNIFE )
   return PLUGIN_CONTINUE

       // Never Run Out of Ammo!
   //server_print("STATUS ID=%d CLIP=%d, AMMO=%d WPN=%d", id, clip, ammo,
   wpn_id)
       if ( clip == 0 )
       {
   //server_print("INVOKING   PUNISHER   MODE!   ID=%d  CLIP=%d,  AMMO=%d
   WPN=%d", id, clip, ammo, wpn_id)
         get_weaponname(wpn_id,wpn,31)
       if (get_cvar_num("sv_dropgunz")==1)
      {
       engclient_cmd(id,"drop",wpn)  //TEST
       }
         give_item(id,wpn)
         engclient_cmd(id, wpn )
         engclient_cmd(id,  wpn  )  //  Checking  to see if multple sends
   helps - sometimes this doesn't work... ;-(
         engclient_cmd(id,  wpn  )  //  Checking  to see if multple sends
   helps - sometimes this doesn't work... ;-(
       }
       return PLUGIN_CONTINUE
   }
   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
   }
