
   /* AMX Mod script.
   *
   * Alternate Shop 1.3
   *  by SniperBeamer
   *
   *
   * Description:
   *  This plugin replaces the default buy menu and the ammo buying.
   *  It's  exactly  like  the  default,  but you can edit the prices and
   change some things.
   *  There are also some extra features.
   *
   * CVARs:
   *  buy_time - obey buytime (0/1)
   *  mp_buytime - sets buytime (minutes)
   *  buy_zone - obey buyzone (0/1)
   *  buy_team - obey team (0/1)
   *  buy_multi - buy more than on sec/prim weapon (0/1)
   *  buy_grenades - how many HEs per round (0 to disable)
   *  buy_vip - vips cannot buy anything (0/1)
   *
   * Commands:
   *  buy_cost - sets the cost of a weapon ( <weapon> <money> )
   *  buy_resetcost - resets the cost of a weapon
   *  buy_restrict  -  restrict  buying  for  a player ( <authid, nick or
   #userid> <0/1> )
   *
   */
   //--------------------------------------------------------------------
   --------------------------
   #include <amxmod>
   #include <amxmisc>
   //--------------------------------------------------------------------
   --------------------------
   #define ADMIN_SHOP ADMIN_LEVEL_B
   //--------------------------------------------------------------------
   --------------------------
   new wCost[31]
   new bool:BuyTimeAllow
   new bool:BuyZoneAllow[33]
   new bool:BuyRestrict[33]
   new BuyProtect[33]
   new Float:BuyTimeFloat
   new BuyTimeNum
   new bool:BuyTimeCvar
   new bool:BuyZoneCvar
   new bool:BuyTeamCvar
   new bool:BuyMultiCvar
   new BuyGrenadesCvar
   new bool:BuyVipCvar
   new vip
   new bool:DeMap
   new bool:KevlarHelmet[33]
   new bool:DefuseKit[33]
   new gmsgFade
   new bool:NightVision[33]
   new bool:NightVisionUse[33]
   //--------------------------------------------------------------------
   --------------------------
   public plugin_init()
   {
       register_plugin("Alternate Shop","1.3","SniperBeamer")
       register_event("RoundTime","RoundTime","bc")
       register_event("StatusIcon","BuyIcon","be","2=buyzone")
       register_event("ResetHUD","NewRound","b")
       register_event("DeathMsg","PlayerDeath","a")
       register_event("TextMsg","RestartRoundTask","a","2&#Game_will_rest
   art_in")
       register_event("Battery","vip_spawn","b","1=200")
       register_cvar("alternate_shop","1.3",FCVAR_SPONLY)
       register_cvar("buy_time","1")
       register_cvar("buy_zone","1")
       register_cvar("buy_team","1")
       register_cvar("buy_multi","0")
       register_cvar("buy_grenades","0")
       register_cvar("buy_vip","1")
       register_menucmd(register_menuid("Buy Item"),1023,"BuyMenuAction")
       register_menucmd(register_menuid("Buy
   Handgun"),1023,"HandMenuAction")
       register_menucmd(register_menuid("Buy
   Shotgun"),1023,"ShotMenuAction")
       register_menucmd(register_menuid("Buy                  Sub-Machine
   Gun"),1023,"SubMenuAction")
       register_menucmd(register_menuid("Buy                      Assault
   Rifle"),1023,"RifleMenuAction")
       register_menucmd(register_menuid("Buy                      Machine
   Gun"),1023,"MachineMenuAction")
       register_menucmd(register_menuid("Buy
   Equipment"),1023,"EquipMenuAction")
       // admin commands
       register_concmd("buy_cost","CostCom",ADMIN_SHOP,"<weapon>
   <money>")
       register_concmd("buy_resetcost","resetCost",ADMIN_SHOP)
       register_concmd("buy_restrict","restrictBuy",ADMIN_SHOP,"<authid,
   nick or #userid> <0/1>")
       // buy commands
       register_clcmd("buy","BuyMenu")
       register_clcmd("buyequip","EquipMenu")
       register_clcmd("buyammo1","PriTask")
       register_clcmd("buyammo2","SecTask")
       // 1.6 buy commands
       register_clcmd("usp","buy_usp")
       register_clcmd("glock","buy_glock")
       register_clcmd("deagle","buy_deagle")
       register_clcmd("p228","buy_p228")
       register_clcmd("elites","buy_elites")
       register_clcmd("fn57","buy_fn57")
       register_clcmd("m3","buy_m3")
       register_clcmd("xm1014","buy_xm1014")
       register_clcmd("mp5","buy_mp5")
       register_clcmd("tmp","buy_tmp")
       register_clcmd("p90","buy_p90")
       register_clcmd("mac10","buy_mac10")
       register_clcmd("ump45","buy_ump45")
       register_clcmd("ak47","buy_ak47")
       register_clcmd("sg552","buy_sg552")
       register_clcmd("m4a1","buy_m4a1")
       register_clcmd("aug","buy_aug")
       register_clcmd("scout","buy_scout")
       register_clcmd("awp","buy_awp")
       register_clcmd("g3sg1","buy_g3sg1")
       register_clcmd("sg550","buy_sg550")
       register_clcmd("m249","buy_m249")
       register_clcmd("primammo","buy_primammo")
       register_clcmd("secammo","buy_secammo")
       register_clcmd("vest","buy_vest")
       register_clcmd("vesthelm","buy_vesthelm")
       register_clcmd("flash","buy_flash")
       register_clcmd("hegren","buy_hegren")
       register_clcmd("sgren","buy_sgren")
       register_clcmd("defuser","buy_defuser")
       register_clcmd("nvgs","buy_nvgs")
       // NightVision
       register_clcmd("nightvision","ToggleNVG")
       gmsgFade = get_user_msgid("ScreenFade")
       // check if is de_ map
       new cMap[32]
       get_mapname(cMap,31)
       if ( equali(cMap,"de_",3) || equali(cMap,"csde_",5) ) DeMap = true
       else DeMap = false
       // set default costs
       setCost()
   }
   //--------------------------------------------------------------------
   --------------------------
   public client_connect(id) // reset some settings
   {
       BuyRestrict[id] = false // unrestrict buying
       KevlarHelmet[id] = false // no Kevlar&Helmet is bought
       NightVision[id] = false // cannot use NightVision
       DefuseKit[id] = false // no Defuse Kit is bought
       BuyProtect[id] = 0 // reset bought HEs
   }
   //--------------------------------------------------------------------
   --------------------------
   public client_disconnect(id)
   {
       if (NightVisionUse[id]) StopNVG(id) // stop NightVision
   }
   //--------------------------------------------------------------------
   --------------------------
   public RoundTime()
   {
       if      (      read_data(1)==get_cvar_num("mp_freezetime")      ||
   read_data(1)==6 ) // freezetime starts
       {
           remove_task(701) // remove buytime task
           BuyTimeAllow = true
           BuyTimeFloat = get_cvar_float("mp_buytime") * 60
           BuyTimeNum = floatround(BuyTimeFloat,floatround_floor)
           BuyTimeCvar = (get_cvar_num("buy_time")) ? true : false
           BuyZoneCvar = (get_cvar_num("buy_zone")) ? true : false
           BuyTeamCvar = (get_cvar_num("buy_team")) ? true : false
           BuyMultiCvar = (get_cvar_num("buy_multi")) ? true : false
           BuyGrenadesCvar = get_cvar_num("buy_grenades")
           BuyVipCvar = (get_cvar_num("buy_vip")) ? true : false
       }
       else // freezetime is over
       {
           set_task(BuyTimeFloat,"BuyTimeTask",701)
       }
       return PLUGIN_CONTINUE
   }
   //--------------------------------------------------------------------
   --------------------------
   public BuyTimeTask()
   {
       BuyTimeAllow = false // buytime is over
   }
   //--------------------------------------------------------------------
   --------------------------
   public BuyIcon(id) // player is in buyzone?
   {
       if (read_data(1))
           BuyZoneAllow[id] = true
       else
           BuyZoneAllow[id] = false
       return PLUGIN_CONTINUE
   }
   //--------------------------------------------------------------------
   --------------------------
   public NewRound(id)
   {
       BuyProtect[id] = 0 // reset bought HEs
       if (NightVisionUse[id]) StopNVG(id) // stop NightVision
       return PLUGIN_CONTINUE
   }
   //--------------------------------------------------------------------
   --------------------------
   public PlayerDeath()
   {
       new victim_id = read_data(2)
       NightVision[victim_id] = false
       if    (NightVisionUse[victim_id])   StopNVG(victim_id)   //   stop
   NightVision
       DefuseKit[victim_id] = false // no Defuse Kit is bought
       KevlarHelmet[victim_id] = false // no Kevlar&Helmet is bought
       return PLUGIN_CONTINUE
   }
   //--------------------------------------------------------------------
   --------------------------
   public RestartRoundTask()
   {
       set_task(get_cvar_float("sv_restart")-0.1,"RestartRound")
   }
   //--------------------------------------------------------------------
   --------------------------
   public RestartRound()
   {
       new players[32],num
       get_players(players,num,"a")
       for (new i=0; i<num; i++)
       {
           DefuseKit[players[i]] = false // no Defuse Kit is bought
           KevlarHelmet[players[i]] = false // no Kevlar&Helmet is bought
           NightVision[players[i]] = false // nobody can use NightVision
       }
       return PLUGIN_CONTINUE
   }
   public vip_spawn(id)
   {
       vip = id
   }
   //--------------------------------------------------------------------
   --------------------------
   public Check(id) // check if player can buy
   {
       if  (  !is_user_alive(id)  ||  (!BuyZoneAllow[id]&&BuyZoneCvar) ||
   BuyRestrict[id] || (BuyVipCvar&&vip==id) )
           return false
       if (BuyTimeCvar)
       {
           if (!CheckTime(id))
               return false
       }
       return true
   }
   //--------------------------------------------------------------------
   --------------------------
   public CheckTime(id) // check buytime
   {
       if (!BuyTimeAllow)
       {
           client_print(id,print_center,"%d seconds have passed...^n^nYou
   can't buy anything now!",BuyTimeNum)
           return false
       }
       return true
   }
   //--------------------------------------------------------------------
   --------------------------
   public Money(id,num) // check money
   {
       new userMoney = get_user_money(id)-wCost[num]
       if (userMoney < 0)
       {
           client_print(id,print_center,"You have insufficient funds!")
           return false
       }
       set_user_money(id,userMoney)
       return true
   }
   //--------------------------------------------------------------------
   --------------------------
   public PrimWeapon(id,bid,bnum) // buy primary weapon
   {
       new weapons[32],num,dropW
       get_user_weapons(id,weapons,num)
       for (new i=0; i<num; i++)
           if (weapons[i]==bid) // abort if already have this weapon
               return PLUGIN_HANDLED
       if (!Money(id,bnum)) return PLUGIN_HANDLED
       get_user_weapons(id,weapons,num)
       for (new i=0; i<num; i++)
           if (isPrimary(weapons[i]))
           {
               dropW = weapons[i] // save primary weapon
               break
           }
       GiveWeapon(id,bid,dropW)
       return PLUGIN_HANDLED
   }
   //--------------------------------------------------------------------
   --------------------------
   public SecWeapon(id,bid,bnum) // buy secondary weapon
   {
       new weapons[32],num,dropW
       get_user_weapons(id,weapons,num)
       for (new i=0; i<num; i++)
           if (weapons[i]==bid) // abort if already have this weapon
               return PLUGIN_HANDLED
       if (!Money(id,bnum)) return PLUGIN_HANDLED
       get_user_weapons(id,weapons,num)
       for (new i=0; i<num; i++)
           if (isSecondary(weapons[i]))
           {
               dropW = weapons[i] // save secondary weapon
               break
           }
       GiveWeapon(id,bid,dropW)
       return PLUGIN_HANDLED
   }
   //--------------------------------------------------------------------
   --------------------------
   public GiveWeapon(id,weapon,dropW) // give weapon
   {
       new weapons[32],num
       get_user_weapons(id,weapons,num)
       new wpName[24]
       get_weaponname(weapon,wpName,23)
       if (is_user_alive(id)) give_item(id,wpName)
       if (dropW!=0&&!BuyMultiCvar) DropWeapon(id,dropW)
   }
   //--------------------------------------------------------------------
   --------------------------
   public DropWeapon(id,weapon) // drop weapon saved before
   {
       new wpName[24]
       get_weaponname(weapon,wpName,23)
       client_cmd(id,"drop %s",wpName)
   }
   //--------------------------------------------------------------------
   --------------------------
   public isPrimary(weapon) // check if weapon is primary
   {
       if
   (weapon==CSW_M3||weapon==CSW_XM1014||weapon==CSW_MP5NAVY||weapon==CSW_
   TMP||weapon==CSW_P90||weapon==CSW_MAC10

   ||weapon==CSW_UMP45||weapon==CSW_AK47||weapon==CSW_SG552||weapon==CSW_
   M4A1||weapon==CSW_AUG||weapon==CSW_SCOUT

   ||weapon==CSW_AWP||weapon==CSW_G3SG1||weapon==CSW_SG550||weapon==CSW_M
   249)
           return true
       return false
   }
   //--------------------------------------------------------------------
   --------------------------
   public isSecondary(weapon) // check if weapon is secondary
   {
       if
   (weapon==CSW_USP||weapon==CSW_GLOCK18||weapon==CSW_DEAGLE||weapon==CSW
   _P228||weapon==CSW_ELITE||weapon==CSW_FIVESEVEN)
           return true
       return false
   }
   //--------------------------------------------------------------------
   --------------------------
   public CheckMaxPriAmmo(id) // check if primary ammo is full
   {
       new weapons[32],num,clip,cammo
       get_user_weapons(id,weapons,num)
       for (new i=0; i<num; i++)
       {
           get_user_ammo(id,weapons[i],clip,cammo)
           switch (weapons[i])
           {
               case CSW_M3:        if (cammo!=32) return true
               case CSW_XM1014:    if (cammo!=32) return true
               case CSW_MP5NAVY:    if (cammo!=120) return true
               case CSW_TMP:        if (cammo!=120) return true
               case CSW_P90:        if (cammo!=100) return true
               case CSW_MAC10:        if (cammo!=100) return true
               case CSW_UMP45:        if (cammo!=100) return true
               case CSW_AK47:        if (cammo!=90) return true
               case CSW_SG552:        if (cammo!=90) return true
               case CSW_M4A1:        if (cammo!=90) return true
               case CSW_AUG:        if (cammo!=90) return true
               case CSW_SCOUT:        if (cammo!=90) return true
               case CSW_AWP:        if (cammo!=30) return true
               case CSW_G3SG1:        if (cammo!=90) return true
               case CSW_SG550:        if (cammo!=90) return true
               case CSW_M249:        if (cammo!=200) return true
           }
       }
       return false
   }
   //--------------------------------------------------------------------
   --------------------------
   public CheckMaxSecAmmo(id) // check if secondary ammo is full
   {
       new weapons[32],num,clip,cammo
       get_user_weapons(id,weapons,num)
       for (new i=0; i<num; i++)
       {
           get_user_ammo(id,weapons[i],clip,cammo)
           switch (weapons[i])
           {
               case CSW_USP:        if (cammo!=100) return true
               case CSW_GLOCK18:    if (cammo!=120) return true
               case CSW_DEAGLE:    if (cammo!=35) return true
               case CSW_P228:        if (cammo!=52) return true
               case CSW_ELITE:        if (cammo!=120) return true
               case CSW_FIVESEVEN:    if (cammo!=100) return true
           }
       }
       return false
   }
   //--------------------------------------------------------------------
   --------------------------
   public  PriTask(id)  //  task  for  buying  primary  ammo  (because of
   buyscripts)
   {
       new ids[3]
       num_to_str(id,ids,3)
       set_task(0.1,"PrimaryAmmo",0,ids,3)
       return PLUGIN_HANDLED
   }
   //--------------------------------------------------------------------
   --------------------------
   public  SecTask(id)  //  task  for  buying  secondary ammo (because of
   buyscripts)
   {
       new ids[3]
       num_to_str(id,ids,3)
       set_task(0.1,"SecondaryAmmo",0,ids,3)
       return PLUGIN_HANDLED
   }
   //--------------------------------------------------------------------
   --------------------------
   public PrimaryAmmo(ids[]) // give primary ammo
   {
       new id = str_to_num(ids)
       if (!Check(id) || !CheckMaxPriAmmo(id)) return PLUGIN_HANDLED
       if (!Money(id,22)) return PLUGIN_HANDLED
       new weapons[32],num
       get_user_weapons(id,weapons,num)
       for (new i=0; i<num; i++)
           switch (weapons[i])
           {
               case CSW_M3:        give_item(id,"ammo_buckshot")
               case CSW_XM1014:    give_item(id,"ammo_buckshot")
               case CSW_MP5NAVY:    give_item(id,"ammo_9mm")
               case CSW_TMP:        give_item(id,"ammo_9mm")
               case CSW_P90:        give_item(id,"ammo_57mm")
               case CSW_MAC10:        give_item(id,"ammo_45acp")
               case CSW_UMP45:        give_item(id,"ammo_45acp")
               case CSW_AK47:        give_item(id,"ammo_762nato")
               case CSW_SG552:        give_item(id,"ammo_556nato")
               case CSW_M4A1:        give_item(id,"ammo_556nato")
               case CSW_AUG:        give_item(id,"ammo_556nato")
               case CSW_SCOUT:        give_item(id,"ammo_762nato")
               case CSW_AWP:        give_item(id,"ammo_338magnum")
               case CSW_G3SG1:        give_item(id,"ammo_762nato")
               case CSW_SG550:        give_item(id,"ammo_556nato")
               case CSW_M249:        give_item(id,"ammo_556natobox")
           }
       return PLUGIN_HANDLED
   }
   //--------------------------------------------------------------------
   --------------------------
   public SecondaryAmmo(ids[]) // give secondary ammo
   {
       new id = str_to_num(ids)
       if (!Check(id) || !CheckMaxSecAmmo(id)) return PLUGIN_HANDLED
       if (!Money(id,23)) return PLUGIN_HANDLED
       new weapons[32],num
       get_user_weapons(id,weapons,num)
       for (new i=0; i<num; i++)
           switch (weapons[i])
           {
               case CSW_USP:        give_item(id,"ammo_45acp")
               case CSW_GLOCK18:    give_item(id,"ammo_9mm")
               case CSW_DEAGLE:    give_item(id,"ammo_50ae")
               case CSW_P228:        give_item(id,"ammo_357sig")
               case CSW_ELITE:        give_item(id,"ammo_9mm")
               case CSW_FIVESEVEN:    give_item(id,"ammo_57mm")
           }
       return PLUGIN_HANDLED
   }
   //--------------------------------------------------------------------
   --------------------------
   public BuyMenuAction(id,key)
   {
       if (!Check(id)) return PLUGIN_HANDLED
       switch (key){
           case 0: HandMenu(id)
           case 1: ShotMenu(id)
           case 2: SubMenu(id)
           case 3: RifleMenu(id)
           case 4: MachineMenu(id)
           case 5: buy_primammo(id)
           case 6: buy_secammo(id)
           case 7: EquipMenu(id)
       }
       return PLUGIN_HANDLED
   }
   //--------------------------------------------------------------------
   --------------------------
   public BuyMenu(id)
   {
       if (!Check(id)) return PLUGIN_HANDLED
       new menuBody[512]
       format(menuBody,511,"\yBuy  Item^n^n\w1.  Handgun^n2.  Shotgun^n3.
   Sub-Machine   Gun^n4.   Rifle^n5.  Machine  Gun^n^n6.  Primary  weapon
   ammo^n7. Secondary weapon ammo^n^n8. Equipment^n^n0. Exit")
       show_menu(id,((1<<0)|(1<<1)|(1<<2)|(1<<3)|(1<<4)|(1<<5)|(1<<6)|(1<
   <7)|(1<<8)|(1<<9)),menuBody)
       return PLUGIN_HANDLED
   }
   //--------------------------------------------------------------------
   --------------------------
   public HandMenuAction(id,key)
   {
       if (!Check(id)) return PLUGIN_HANDLED
       switch (key)
       {
           case 0: SecWeapon(id,CSW_USP,0)
           case 1: SecWeapon(id,CSW_GLOCK18,1)
           case 2: SecWeapon(id,CSW_DEAGLE,2)
           case 3: SecWeapon(id,CSW_P228,3)
           case 4:{
               if       ((get_user_team(id)==2)&&BuyTeamCvar)      return
   PLUGIN_HANDLED
               SecWeapon(id,CSW_ELITE,4)
           }
           case 5:{
               if       ((get_user_team(id)==1)&&BuyTeamCvar)      return
   PLUGIN_HANDLED
               SecWeapon(id,CSW_FIVESEVEN,5)
           }
       }
       return PLUGIN_HANDLED
   }
   //--------------------------------------------------------------------
   --------------------------
   public HandMenu(id)
   {
       if (!Check(id)) return PLUGIN_HANDLED
       new Team = get_user_team(id)
       new menuBody[512]
       new len = format(menuBody,511,"\yBuy Handgun\R$   Cost^n(Secondary
   weapon)^n^n\w1.   H&K  USP  .45  Tactical\R\y%d^n\w2.  Glock18  Select
   Fire\R\y%d^n\w3.      Desert      Eagle      .50AE\R\y%d^n\w4.     SIG
   P228\R\y%d^n",wCost[0],wCost[1],wCost[2],wCost[3])
       if ( (Team==1)&&(BuyTeamCvar) )
           len  +=  format(menuBody[len],511-len,"\w5.  Dual  Beretta 96G
   Elite\R\y%d^n\d6. FN Five-Seven\R\y%d^n^n\w0. Exit",wCost[4],wCost[5])
       else if ( (Team==2)&&(BuyTeamCvar) )
           len  +=  format(menuBody[len],511-len,"\d5.  Dual  Beretta 96G
   Elite\R\y%d^n\w6. FN Five-Seven\R\y%d^n^n\w0. Exit",wCost[4],wCost[5])
       else
           len  +=  format(menuBody[len],511-len,"\w5.  Dual  Beretta 96G
   Elite\R\y%d^n\w6. FN Five-Seven\R\y%d^n^n\w0. Exit",wCost[4],wCost[5])
       show_menu(id,((1<<0)|(1<<1)|(1<<2)|(1<<3)|(1<<4)|(1<<5)|(1<<9)),me
   nuBody)
       return PLUGIN_HANDLED
   }
   //--------------------------------------------------------------------
   --------------------------
   public ShotMenuAction(id,key)
   {
       if (!Check(id)) return PLUGIN_HANDLED
       switch (key)
       {
           case 0: PrimWeapon(id,CSW_M3,6)
           case 1: PrimWeapon(id,CSW_XM1014,7)
       }
       return PLUGIN_HANDLED
   }
   //--------------------------------------------------------------------
   --------------------------
   public ShotMenu(id)
   {
       if (!Check(id)) return PLUGIN_HANDLED
       new menuBody[512]
       format(menuBody,511,"\yBuy             Shotgun\R$   Cost^n(Primary
   weapon)^n^n\w1.      Benelli      M3     Super\R\y%d^n\w2.     Benelli
   XM1014\R\y%d^n^n\w0. Exit",wCost[6],wCost[7])
       show_menu(id,((1<<0)|(1<<1)|(1<<9)),menuBody)
       return PLUGIN_HANDLED
   }
   //--------------------------------------------------------------------
   --------------------------
   public SubMenuAction(id,key)
   {
       if (!Check(id)) return PLUGIN_HANDLED
       switch (key)
       {
           case 0: PrimWeapon(id,CSW_MP5NAVY,8)
           case 1:{
               if       ((get_user_team(id)==1)&&BuyTeamCvar)      return
   PLUGIN_HANDLED
               PrimWeapon(id,CSW_TMP,9)
           }
           case 2: PrimWeapon(id,CSW_P90,10)
           case 3:{
               if       ((get_user_team(id)==2)&&BuyTeamCvar)      return
   PLUGIN_HANDLED
               PrimWeapon(id,CSW_MAC10,11)
           }
           case 4: PrimWeapon(id,CSW_UMP45,12)
       }
       return PLUGIN_HANDLED
   }
   //--------------------------------------------------------------------
   --------------------------
   public SubMenu(id)
   {
       if (!Check(id)) return PLUGIN_HANDLED
       new Team = get_user_team(id)
       new menuBody[512]
       new      len      =     format(menuBody,511,"\yBuy     Sub-Machine
   Gun\R$   Cost^n(Primary weapon)^n^n\w1. H&K
   MP5-Navy\R\y%d^n",wCost[8])
       if ( (Team==2)||(!BuyTeamCvar) )
           len   +=   format(menuBody[len],511-len,"\w2.  Steyr  Tactical
   Machine Pistol\R\y%d^n",wCost[9])
       else
           len   +=   format(menuBody[len],511-len,"\d2.  Steyr  Tactical
   Machine Pistol\R\y%d^n",wCost[9])
       len         +=        format(menuBody[len],511-len,"\w3.        FN
   P90\R\y%d^n",wCost[10])
       if ( (Team==1)||(!BuyTeamCvar) )
           len      +=      format(menuBody[len],511-len,"\w4.     Ingram
   MAC-10\R\y%d^n",wCost[11])
       else
           len      +=      format(menuBody[len],511-len,"\d4.     Ingram
   MAC-10\R\y%d^n",wCost[11])
       len  += format(menuBody[len],511-len,"\w5. H&K UMP45\R\y%d^n^n\w0.
   Exit",wCost[12])
       show_menu(id,((1<<0)|(1<<1)|(1<<2)|(1<<3)|(1<<4)|(1<<9)),menuBody)
       return PLUGIN_HANDLED
   }
   //--------------------------------------------------------------------
   --------------------------
   public RifleMenuAction(id,key)
   {
       if (!Check(id)) return PLUGIN_HANDLED
       switch (key)
       {
           case 0:{
               if       ((get_user_team(id)==2)&&BuyTeamCvar)      return
   PLUGIN_HANDLED
               PrimWeapon(id,CSW_AK47,13)
           }
           case 1:{
               if       ((get_user_team(id)==2)&&BuyTeamCvar)      return
   PLUGIN_HANDLED
               PrimWeapon(id,CSW_SG552,14)
           }
           case 2:{
               if       ((get_user_team(id)==1)&&BuyTeamCvar)      return
   PLUGIN_HANDLED
               PrimWeapon(id,CSW_M4A1,15)
           }
           case 3:{
               if       ((get_user_team(id)==1)&&BuyTeamCvar)      return
   PLUGIN_HANDLED
               PrimWeapon(id,CSW_AUG,16)
           }
           case 4: PrimWeapon(id,CSW_SCOUT,17)
           case 5: PrimWeapon(id,CSW_AWP,18)
           case 6:{
               if       ((get_user_team(id)==2)&&BuyTeamCvar)      return
   PLUGIN_HANDLED
               PrimWeapon(id,CSW_G3SG1,19)
           }
           case 7:{
               if       ((get_user_team(id)==1)&&BuyTeamCvar)      return
   PLUGIN_HANDLED
               PrimWeapon(id,CSW_SG550,20)
           }
       }
       return PLUGIN_HANDLED
   }
   //--------------------------------------------------------------------
   --------------------------
   public RifleMenu(id)
   {
       if (!Check(id)) return PLUGIN_HANDLED
       new Team = get_user_team(id)
       new menuBody[512]
       new   len  =  format(menuBody,511,"\yBuy  Assault  Rifle  (Primary
   weapon)\R$   Cost^n^n")
       if ( (Team==1)||(!BuyTeamCvar) )
           len  +=  format(menuBody[len],511-len,"\w1.  AK-47\R\y%d^n\w2.
   Sig SG-552 Commando\R\y%d^n",wCost[13],wCost[14])
       else
           len  +=  format(menuBody[len],511-len,"\d1.  AK-47\R\y%d^n\d2.
   Sig SG-552 Commando\R\y%d^n",wCost[13],wCost[14])
       if ( (Team==2)||(!BuyTeamCvar) )
           len    +=    format(menuBody[len],511-len,"\w3.    Colt   M4A1
   Carbine\R\y%d^n\w4. Steyr Aug\R\y%d",wCost[15],wCost[16])
       else
           len    +=    format(menuBody[len],511-len,"\d3.    Colt   M4A1
   Carbine\R\y%d^n\d4. Steyr Aug\R\y%d",wCost[15],wCost[16])
       len   +=   format(menuBody[len],511-len,"^n^n\yBuy   Sniper  Rifle
   (Primary    weapon)^n^n\w5.    Steyr   Scout\R\y%d^n\w6.   AI   Arctic
   Warfare/Magnum\R\y%d^n",wCost[17],wCost[18])
       if ( (Team==1)||(!BuyTeamCvar) )
           len  +=  format(menuBody[len],511-len,"\w7. H&K G3/SG-1 Sniper
   Rifle\R\y%d^n",wCost[19])
       else
           len  +=  format(menuBody[len],511-len,"\d7. H&K G3/SG-1 Sniper
   Rifle\R\y%d^n",wCost[19])
       if ( (Team==2)||(!BuyTeamCvar) )
           len    +=    format(menuBody[len],511-len,"\w8.   Sig   SG-550
   Sniper\R\y%d^n^n\w0. Exit",wCost[20])
       else
           len    +=    format(menuBody[len],511-len,"\d8.   Sig   SG-550
   Sniper\R\y%d^n^n\w0. Exit",wCost[20])
       show_menu(id,((1<<0)|(1<<1)|(1<<2)|(1<<3)|(1<<4)|(1<<5)|(1<<6)|(1<
   <7)|(1<<9)),menuBody)
       return PLUGIN_HANDLED
   }
   //--------------------------------------------------------------------
   --------------------------
   public MachineMenuAction(id,key)
   {
       if (key==0) PrimWeapon(id,CSW_M249,21)
       return PLUGIN_HANDLED
   }
   //--------------------------------------------------------------------
   --------------------------
   public MachineMenu(id)
   {
       if (!Check(id)) return PLUGIN_HANDLED
       new menuBody[512]
       format(menuBody,511,"\yBuy     Machine     Gun\R$   Cost^n(Primary
   weapon)^n^n\w1. FN M249 Para\R\y%d^n^n\w0. Exit",wCost[21])
       show_menu(id,((1<<0)|(1<<9)),menuBody)
       return PLUGIN_HANDLED
   }
   //--------------------------------------------------------------------
   --------------------------
   public EquipMenuAction(id,key)
   {
       if (!Check(id)) return PLUGIN_HANDLED
       switch (key)
       {
           case 0:{
               if (get_user_armor(id)==100) return PLUGIN_HANDLED
               if (!Money(id,24)) return PLUGIN_HANDLED
               give_item(id,"item_kevlar")
               KevlarHelmet[id] = false
           }
           case 1:{
               if    (get_user_armor(id)==100&&KevlarHelmet[id])   return
   PLUGIN_HANDLED
               if (!Money(id,25)) return PLUGIN_HANDLED
               give_item(id,"item_assaultsuit")
               KevlarHelmet[id] = true
           }
           case 2:{
               new weapons[32],num
               get_user_weapons(id,weapons,num)
               for (new i=0; i<num; i++)
                   if (weapons[i]==CSW_FLASHBANG)
                   {
                       new clip,ammo
                       get_user_ammo(id,weapons[i],clip,ammo)
                       if (clip+ammo==1) return PLUGIN_HANDLED
                   }
               if (!Money(id,26)) return PLUGIN_HANDLED
               give_item(id,"weapon_flashbang")
           }
           case 3:{
               new weapons[32],num
               get_user_weapons(id,weapons,num)
               for (new i=0; i<num; i++)
                   if (weapons[i]==CSW_HEGRENADE) return PLUGIN_HANDLED
               if  ( BuyGrenadesCvar>0 && BuyGrenadesCvar==BuyProtect[id]
   )
               {
                   new Gren[2]
                   if (BuyGrenadesCvar==1) copy(Gren,1,"")
                   else copy(Gren,1,"s")
                   client_print(id,print_center,"You  can  only buy %d HE
   Grenade%s per round!",BuyGrenadesCvar,Gren)
                   return PLUGIN_HANDLED
               }
               if (!Money(id,27)) return PLUGIN_HANDLED
               give_item(id,"weapon_hegrenade")
               BuyProtect[id]++
           }
           case 4:{
               new weapons[32],num
               get_user_weapons(id,weapons,num)
               for (new i=0; i<num; i++)
                   if        (weapons[i]==CSW_SMOKEGRENADE)        return
   PLUGIN_HANDLED
               if (!Money(id,28)) return PLUGIN_HANDLED
               give_item(id,"weapon_smokegrenade")
           }
           case 5:{
               if (
   (get_user_team(id)==1&&BuyTeamCvar)||!DeMap||DefuseKit[id]   )  return
   PLUGIN_HANDLED
               if (!Money(id,29)) return PLUGIN_HANDLED
               give_item(id,"item_thighpack")
               DefuseKit[id] = true
           }
           case 6:{
               if (NightVision[id]) return PLUGIN_HANDLED
               if (!Money(id,30)) return PLUGIN_HANDLED
               NightVision[id] = true
           }
       }
       return PLUGIN_HANDLED
   }
   //--------------------------------------------------------------------
   --------------------------
   public EquipMenu(id)
   {
       if (!Check(id)) return PLUGIN_HANDLED
       new Team = get_user_team(id)
       new menuBody[512]
       new  len  = format(menuBody,511,"\yBuy Equipment\R$   Cost^n^n\w1.
   Kevlar    Vest\R\y%d^n\w2.    Kevlar    Vest    &   Helmet\R\y%d^n\w3.
   Flashbang\R\y%d^n",wCost[24],wCost[25],wCost[26])
       if ( BuyGrenadesCvar>0 && BuyGrenadesCvar==BuyProtect[id] )
           len       +=       format(menuBody[len],511-len,"\d4.       HE
   Grenade\R\y%d^n",wCost[27])
       else
           len       +=       format(menuBody[len],511-len,"\w4.       HE
   Grenade\R\y%d^n",wCost[27])

       len        +=       format(menuBody[len],511-len,"\w5.       Smoke
   Grenade\R\y%d^n",wCost[28])
       if ( ((Team==2)||(!BuyTeamCvar))&&DeMap )
           len      +=      format(menuBody[len],511-len,"\w6.     Defuse
   Kit\R\y%d^n",wCost[29])
       else
           len      +=      format(menuBody[len],511-len,"\d6.     Defuse
   Kit\R\y%d^n",wCost[29])
       len      +=     format(menuBody[len],511-len,"\d7.     NightVision
   Goggles\R\y%d^n^n\w0. Exit",wCost[30])
       show_menu(id,((1<<0)|(1<<1)|(1<<2)|(1<<3)|(1<<4)|(1<<5)|(1<<6)|(1<
   <9)),menuBody)
       return PLUGIN_HANDLED
   }
   //--------------------------------------------------------------------
   --------------------------
   public setCost() // default costs
   {
       wCost[0] = 500        // 11: H&K USP .45 Tactical (CSW_USP)
       wCost[1] = 400        // 12: Glock18 Select Fire (CSW_GLOCK18)
       wCost[2] = 650        // 13: Desert Eagle .50AE (CSW_DEAGLE)
       wCost[3] = 600        // 14: SIG P228 (CSW_P228)
       wCost[4] = 1000        // 15: Dual Beretta 96G Elite (CSW_ELITE)
       wCost[5] = 750        // 16: FN Five-Seven (CSW_FIVESEVEN)
       wCost[6] = 1700        // 21: Benelli M3 Super (CSW_M3)
       wCost[7] = 3000        // 22: Benelli XM1014 (CSW_XM1014)
       wCost[8] = 1500        // 31: H&K MP5-Navy (CSW_MP5NAVY)
       wCost[9]  =  1250        //  32:  Steyr  Tactical  Machine  Pistol
   (CSW_TMP)
       wCost[10] = 2350    // 33: FN P90 (CSW_P90)
       wCost[11] = 1400    // 34: Ingram MAC-10 (CSW_MAC10)
       wCost[12] = 2350    // 35: H&K UMP45 (CSW_UMP45)
       wCost[13] = 2500    // 41: AK-47 (CSW_AK47)
       wCost[14] = 3500    // 42: Sig SG-552 Commando (CSW_SG552)
       wCost[15] = 3100    // 43: Colt M4A1 Carbine (CSW_M4A1)
       wCost[16] = 3500    // 44: Steyr Aug (CSW_AUG)
       wCost[17] = 2750    // 45: Steyr Scout (CSW_SCOUT)
       wCost[18] = 4750    // 46: AI Arctic Warfare/Magnum (CSW_AWP)
       wCost[19] = 5000    // 47: H&K G3/SG-1 Sniper Rifle (CSW_G3SG1)
       wCost[20] = 4200    // 48: Sig SG-550 Sniper (CSW_SG550)
       wCost[21] = 5750    // 51: FN M249 Para (CSW_M249)
       wCost[22] = 30        // 61: Primary Ammo
       wCost[23] = 25        // 71: Secondary Ammo
       wCost[24] = 650        // 81: Kevlar Vest
       wCost[25] = 1000    // 82: Kevlar Vest & Helmet
       wCost[26] = 200        // 83: Flashbang
       wCost[27] = 300        // 84: HE Grenade
       wCost[28] = 300        // 85: Smoke Grenade
       wCost[29] = 200        // 86: Defuse Kit
       wCost[30] = 1250    // 87: NightVision Goggles
   }
   //--------------------------------------------------------------------
   --------------------------
   public resetCost(id,level,cid) // reset costs command
   {
       if (!cmd_access(id,level,cid,1))
           return PLUGIN_HANDLED
       setCost()
       return PLUGIN_HANDLED
   }
   //--------------------------------------------------------------------
   --------------------------
   public CostCom(id,level,cid) // set cost of a weapon
   {
       if (!cmd_access(id,level,cid,3))
           return PLUGIN_HANDLED
       new arg1[4],arg2[8],num = -1
       read_argv(1,arg1,3)
       read_argv(2,arg2,7)
       new weapon = str_to_num(arg1)
       new money = str_to_num(arg2)
       switch (weapon)
       {
           case 11: num = 0
           case 12: num = 1
           case 13: num = 2
           case 14: num = 3
           case 15: num = 4
           case 16: num = 5
           case 21: num = 6
           case 22: num = 7
           case 31: num = 8
           case 32: num = 9
           case 33: num = 10
           case 34: num = 11
           case 35: num = 12
           case 41: num = 13
           case 42: num = 14
           case 43: num = 15
           case 44: num = 16
           case 45: num = 17
           case 46: num = 18
           case 47: num = 19
           case 48: num = 20
           case 51: num = 21
           case 61: num = 22
           case 71: num = 23
           case 81: num = 24
           case 82: num = 25
           case 83: num = 26
           case 84: num = 27
           case 85: num = 28
           case 86: num = 29
           case 87: num = 30
       }
       if (num==-1) console_print(id,"[AMX] There is no such weapon")
       else
       {
           console_print(id,"[AMX] Set weapon %d to %d$",weapon,money)
           wCost[num] = money
       }
       return PLUGIN_HANDLED
   }
   //--------------------------------------------------------------------
   --------------------------
   public restrictBuy(id,level,cid) // restrict buying for a player
   {
       if (!cmd_access(id,level,cid,2))
           return PLUGIN_HANDLED
       new arg1[32],arg2[4]
       read_argv(1,arg1,31)
       read_argv(2,arg2,3)
       if (equal(arg2,"")) copy(arg2,3,"1")
       new target = cmd_target(id,arg1,3)
       if (!target) return PLUGIN_HANDLED
       new pName[32]
       get_user_name(target,pName,31)
       if (str_to_num(arg2)==0 || equali(arg2,"off"))
       {
           BuyRestrict[target] = false
           console_print(id,"[AMX]      Un-Restricted      buying     for
   ^"%s^"",pName)
       }
       else
       {
           BuyRestrict[target] = true
           console_print(id,"[AMX] Restricted buying for ^"%s^"",pName)
       }
       return PLUGIN_HANDLED
   }
   //--------------------------------------------------------------------
   --------------------------
   // 1.6 buy commands
   public buy_usp(id)
   {
       HandMenuAction(id,0)
       return PLUGIN_HANDLED
   }
   public buy_glock(id)
   {
       HandMenuAction(id,1)
       return PLUGIN_HANDLED
   }
   public buy_deagle(id)
   {
       HandMenuAction(id,2)
       return PLUGIN_HANDLED
   }
   public buy_p228(id)
   {
       HandMenuAction(id,3)
       return PLUGIN_HANDLED
   }
   public buy_elites(id)
   {
       HandMenuAction(id,4)
       return PLUGIN_HANDLED
   }
   public buy_fn57(id)
   {
       HandMenuAction(id,5)
       return PLUGIN_HANDLED
   }
   public buy_m3(id)
   {
       ShotMenuAction(id,0)
       return PLUGIN_HANDLED
   }
   public buy_xm1014(id)
   {
       ShotMenuAction(id,1)
       return PLUGIN_HANDLED
   }
   public buy_mp5(id)
   {
       SubMenuAction(id,0)
       return PLUGIN_HANDLED
   }
   public buy_tmp(id)
   {
       SubMenuAction(id,1)
       return PLUGIN_HANDLED
   }
   public buy_p90(id)
   {
       SubMenuAction(id,2)
       return PLUGIN_HANDLED
   }
   public buy_mac10(id)
   {
       SubMenuAction(id,3)
       return PLUGIN_HANDLED
   }
   public buy_ump45(id)
   {
       SubMenuAction(id,4)
       return PLUGIN_HANDLED
   }
   public buy_ak47(id)
   {
       RifleMenuAction(id,0)
       return PLUGIN_HANDLED
   }
   public buy_sg552(id)
   {
       RifleMenuAction(id,1)
       return PLUGIN_HANDLED
   }
   public buy_m4a1(id)
   {
       RifleMenuAction(id,2)
       return PLUGIN_HANDLED
   }
   public buy_aug(id)
   {
       RifleMenuAction(id,3)
       return PLUGIN_HANDLED
   }
   public buy_scout(id)
   {
       RifleMenuAction(id,4)
       return PLUGIN_HANDLED
   }
   public buy_awp(id)
   {
       RifleMenuAction(id,5)
       return PLUGIN_HANDLED
   }
   public buy_g3sg1(id)
   {
       RifleMenuAction(id,6)
       return PLUGIN_HANDLED
   }
   public buy_sg550(id)
   {
       RifleMenuAction(id,7)
       return PLUGIN_HANDLED
   }
   public buy_m249(id)
   {
       MachineMenuAction(id,0)
       return PLUGIN_HANDLED
   }
   public buy_primammo(id)
   {
       for (new i=0; i<7; i++)
           PriTask(id)
       return PLUGIN_HANDLED
   }
   public buy_secammo(id)
   {
       for (new i=0; i<7; i++)
           SecTask(id)
       return PLUGIN_HANDLED
   }
   public buy_vest(id)
   {
       EquipMenuAction(id,0)
       return PLUGIN_HANDLED
   }
   public buy_vesthelm(id)
   {
       EquipMenuAction(id,1)
       return PLUGIN_HANDLED
   }
   public buy_flash(id)
   {
       EquipMenuAction(id,2)
       return PLUGIN_HANDLED
   }
   public buy_hegren(id)
   {
       EquipMenuAction(id,3)
       return PLUGIN_HANDLED
   }
   public buy_sgren(id)
   {
       EquipMenuAction(id,4)
       return PLUGIN_HANDLED
   }
   public buy_defuser(id)
   {
       EquipMenuAction(id,5)
       return PLUGIN_HANDLED
   }
   public buy_nvgs(id)
   {
       EquipMenuAction(id,6)
       return PLUGIN_HANDLED
   }
   //--------------------------------------------------------------------
   --------------------------
   public ToggleNVG(id)
   {
       if (!NightVision[id]) return PLUGIN_HANDLED
       if (NightVisionUse[id]) StopNVG(id)
       else StartNVG(id)
       return PLUGIN_HANDLED
   }
   //--------------------------------------------------------------------
   --------------------------
   public  StartNVG(id)  //  NightVision  code  by  Lazy  (a  little  bit
   modified)
   {
       new player[32]
       get_user_name(id,player,32)
       emit_sound(id,CHAN_ITEM,"items/nvg_on.wav",1.0,ATTN_NORM,0,PITCH_N
   ORM)
       set_task(0.1,"RunNVG",id+100,player,32,"b") // another task id for
   each player
       set_task(0.1,"RunNVG2",id+200,player,32,"b")
       NightVisionUse[id] = true
       return PLUGIN_HANDLED
   }
   //--------------------------------------------------------------------
   --------------------------
   public StopNVG(id)
   {
       emit_sound(id,CHAN_ITEM,"items/nvg_off.wav",1.0,ATTN_NORM,0,PITCH_
   NORM)
       remove_task(id+100)
       remove_task(id+200)
       NightVisionUse[id] = false
       return PLUGIN_HANDLED
   }
   //--------------------------------------------------------------------
   --------------------------
   public RunNVG(player[])
   {
       new id = get_user_index(player)
       new origin[3]
       get_user_origin(id,origin)
          message_begin(MSG_ONE,SVC_TEMPENTITY,{0,0,0},id)
          write_byte(27)
          write_coord(origin[0])
          write_coord(origin[1])
          write_coord(origin[2])
          write_byte(125)
          write_byte(0)
          write_byte(255)
          write_byte(0)
          write_byte(1)
          write_byte(10)
          message_end()
   }
   //--------------------------------------------------------------------
   --------------------------
   public RunNVG2(player[])
   {
       new id = get_user_index(player)
       message_begin(MSG_ONE,gmsgFade,{0,0,0},id)
       write_short(1000)
       write_short(1000)
       write_short(1<<12)
       write_byte(0)
       write_byte(255)
       write_byte(0)
       write_byte(150)
       message_end()
   }
   //--------------------------------------------------------------------
   --------------------------AMXMOD?>
