
   /* AMX Mod script.
   *
   * BuyKnife 1.0
   *  by AssKicR
   *
   * Requirements
   *  Vexd_Utilities
   *
   * Description:
   *  This plugin makes you buy the knife
   *  (This Plugin is cool to use with Alternate Shop by Sniperbeamer :D)
   *
   * CVARs:
   *  buy_time - take care of buytime (0/1)
   *  mp_buytime - sets buytime (minutes)
   *  buy_zone - take care of buyzone (0/1)
   *  buy_knife  -  must  you  buy  the  knife (0/1) (WARNING::: Can't be
   changed midround)
   *
   * Client Command
   *  buyknife - Buys a knife
   *
   * Admin Command:
   *  buy_costknife - sets the cost of a the knife( < money > )
   *
   */
   #include <amxmod>
   #include <amxmisc>
   #include <Vexd_Utilities>
   new bool:BuyTimeAllow
   new bool:BuyZoneAllow[33]
   new Float:BuyTimeFloat
   new BuyTimeNum
   new bool:BuyTimeCvar
   new bool:BuyZoneCvar
   //--------------------------------------------------------------------
   --------------------------
   public plugin_init() {
       register_plugin("BuyKnife", "1.0", "AssKicR")
       register_cvar("buy_time","1")
       register_cvar("buy_zone","1")
       register_cvar("buy_knife","1")
       register_cvar("sv_knifecost","100")
       register_event("ResetHUD","newRound","b")
       register_clcmd("buyknife","BuyKnife",ADMIN_USER,"")
       register_event("RoundTime","Round_Time","bc")
       register_event("StatusIcon","Buy_Icon","be","2=buyzone")
       register_concmd("buy_costknife","CostCom",ADMIN_LEVEL_B,"<   money
   >")
   }
   //--------------------------------------------------------------------
   --------------------------
   public strip(){
       if (get_cvar_num("buy_knife")==1) {
           new iEntHandle = CreateEntity("game_player_equip")
           DispatchKeyValue(iEntHandle, "weapon_knife", "1")
           DispatchSpawn(iEntHandle)
       //  new Ent = CreateEntity("player_weaponstrip")
       //  Entvars_Set_String(Ent, EV_SZ_targetname, "game_playerspawn")
       }else{
           //Do noting.. We do not want them to loose knife now
       }
       return PLUGIN_CONTINUE
   }
   //--------------------------------------------------------------------
   --------------------------
   public Check(id)
   {
      if ( !is_user_alive(id) || (!BuyZoneAllow[id]&&BuyZoneCvar) )
         return false
      if (BuyTimeCvar)
      {
         if (!CheckTime(id))
            return false
      }
      return true
   }
   //--------------------------------------------------------------------
   --------------------------
   public CostCom(id,level,cid)
   {
      if (!cmd_access(id,level,cid,3))
         return PLUGIN_HANDLED
      new arg1[4]
      read_argv(1,arg1,7)
      new money = str_to_num(arg1)
      {
         console_print(id,"[AMX] Set knife cost to %d$",money)
         set_cvar_num("sv_knifecost",money)
      }
   //--------------------------------------------------------------------
   --------------------------
      return PLUGIN_HANDLED
   }
   public Round_Time()
   {
      if      (      (read_data(1)==get_cvar_num("mp_freezetime"))     ||
   (read_data(1)==6) )
      {
         remove_task(701)
         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
      }
      else
      {
         set_task(BuyTimeFloat,"BuyTimeTask",701)
      }
      return PLUGIN_CONTINUE
   }
   //--------------------------------------------------------------------
   --------------------------
   public BuyTimeTask()
   {
      BuyTimeAllow = false
   }
   //--------------------------------------------------------------------
   --------------------------
   public Buy_Icon(id)
   {
      if (read_data(1))
      {
         BuyZoneAllow[id] = true
      }
      else
      {
         BuyZoneAllow[id] = false
      }
      return PLUGIN_CONTINUE
   }
   //--------------------------------------------------------------------
   --------------------------
   public CheckTime(id)
   {
      if (!BuyTimeAllow)
      {
         client_print(id,print_center,"%d  seconds  have passed...^n^nYou
   can't buy anything now!",BuyTimeNum)
         return false
      }
      return true
   }
   //--------------------------------------------------------------------
   --------------------------
   public newRound(id) {
       if (get_cvar_num("buy_knife")!=1) return PLUGIN_HANDLED
       set_task(1.0,"strip",0,"",0)
       client_print(id,print_chat,"[AMX]  A  knife  costs %i$.. Buy it by
   typing ::: buyknife ::: in console",get_cvar_num("sv_knifecost"))
       return PLUGIN_CONTINUE
   }
   //--------------------------------------------------------------------
   --------------------------
   public BuyKnife(id) {
       if (!Check(id)) return PLUGIN_HANDLED
       if (get_cvar_num("buy_knife")!=1) return PLUGIN_HANDLED
       new cost = get_cvar_num("sv_knifecost")
       new money = get_user_money(id)
       if (money < cost) {
           client_print(id,print_center,"You    need   $%i   to   buy   a
   knife",cost)
           return PLUGIN_CONTINUE
       }else{
           WeaponCheck(id,cost)
           }
       return PLUGIN_CONTINUE
   }
   //--------------------------------------------------------------------
   --------------------------
   public WeaponCheck(id,cost)
     {
       // Yeah just givem the weapon if they don't already have it
       new iwpn, iwpns[32]
       get_user_weapons(id, iwpns,iwpn)
       //server_print("CHECKING Giving:%s", weaponName)
       new ownWeapon[32]
       for(new a = 0; a < iwpn;++a)
       {
           get_weaponname(iwpns[a],ownWeapon,31)
           //server_print("PERSON OWNS %s", ownWeapon)
           if ( equali(ownWeapon, "weapon_knife") ) {
               client_print(id,print_center,"You already have a knife")
               return PLUGIN_CONTINUE
           }
       }
       give_item(id, "weapon_knife")
       set_user_money(id, get_user_money(id) - cost,1)
       return PLUGIN_CONTINUE
     }
   //--------------------------------------------------------------------
   -------------------------- AMXMOD?>
