
   #include <amxmod>
   #include <amxmisc>
   #include <dodxmod>
   new g_GreBase[36] = { 0,
                         2,1,1,1,0,1,0, /* US */
                         2,2,0,1,1,0,0, /* GER */
                         2,1,0,1, /* UK */
                         2,1,1,1,0,1,0, /* US Para */
                         2,2,0,1,1,1,1,0,0 /* GER Para */
                       }
   new g_GreNames[3][] = { 0,"weapon_handgrenade","weapon_stickgrenade" }
   new g_PlayerGre[33]
   new bool:g_GreEnable
   new option[2]
   public plugin_init() {
      register_plugin("Grenade Arena","1.0","SidLuke")
      register_event("CurWeapon","grecatch","be","1=1","2=15","2=16")
      register_event("CurWeapon","switchtonade","be","1=1","2!13","2!14",
   "2!15","2!16")
      register_event("ResetHUD","respawn","be")
      register_concmd("amx_grearena","amx_grearena",ADMIN_LEVEL_B,"<1|0>
   - nades only mode")
      register_clcmd("say  /votegrearena","vote_nades",0,"-  start voting
   session for Nades Arena")
      register_clcmd("say  votegrearena","vote_nades",0,"-  start  voting
   session for Nades Arena")
      register_menucmd(register_menuid("Grenade
   Arena?"),(1<<0)|(1<<1),"vote_count")
      g_GreEnable = false
      return PLUGIN_CONTINUE
   }
   public grenade_throw(id,gre_type) {
      if ( !g_GreEnable ) return PLUGIN_CONTINUE
      g_PlayerGre[id]--
      give_grenades(id)
      return PLUGIN_CONTINUE
   }
   public grecatch(id) {
      if ( !g_GreEnable ) return PLUGIN_CONTINUE
      g_PlayerGre[id]++
      return PLUGIN_CONTINUE
   }
   public switchtonade(id) {
      if ( !g_GreEnable ) return PLUGIN_CONTINUE
      engclient_cmd(id,g_GreNames[dod_get_user_team(id)])
      return PLUGIN_CONTINUE
   }
   public respawn(id) {
      if ( !g_GreEnable ) return PLUGIN_CONTINUE
      new pos = dod_get_user_class(id)
      g_PlayerGre[id] = g_GreBase[pos]
      give_grenades(id)
      return PLUGIN_CONTINUE
   }
   public give_grenades(id) {
      if ( g_PlayerGre[id] == 0 ) {
         give_item(id,g_GreNames[dod_get_user_team(id)])
         g_PlayerGre[id]++
      }
      return PLUGIN_CONTINUE
   }
   public kill_players(){
      for ( new i=1;i<get_maxplayers();i++ ){
         if ( is_user_alive(i) )
            user_kill(i,1)
      }
      return PLUGIN_CONTINUE
   }
   /*******************************************
                      VOTE
   *******************************************/
   public amx_grearena(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") ){
         if ( !g_GreEnable ) kill_players()
         g_GreEnable = true
      }
      else if (equal(arg1,"0")||equali(arg1,"off")){
         g_GreEnable = false
      }
      else {
         console_print(id,"Grenade Arena is %s",g_GreEnable ? "enabled" :
   "disabled")
         return PLUGIN_HANDLED
      }
      console_print(id,"Grenade  Arena  is  %s",g_GreEnable ? "enabled" :
   "disabled")
      client_print(0,print_center,"Grenade       Arena      Has      Been
   %s!",g_GreEnable ? "Enabled" : "Disabled")
      set_hudmessage(0, 100, 0, 0.05, 0.65, 2, 0.02, 10.0, 0.01, 0.1, 2)
      show_hudmessage(0,g_GreEnable  ? "Grenade Arena Activated" : "Nades
   Arena Deactivated" )
      return PLUGIN_HANDLED
   }
   new votearena[] = "AMX %s Grenade Arena?^n^n1. Yes^n2. No"
   public vote_nades(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,votearena,g_GreEnable ? "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_grearena %s",g_GreEnable ? "off" : "on" )
         client_print(0,print_chat,"*  Voting successful (yes ^"%d^") (no
   ^"%d^").",option[0],option[1])
         kill_players()
      }
      else{
         client_print(0,print_chat,"*  Voting  failed  (yes  ^"%d^")  (no
   ^"%d^").",option[0],option[1])
      }
      return PLUGIN_CONTINUE
   }
