
   /* AMX Mod script.
   *
   * (c) Copyright 2002, OLO
   * This file is provided as is (no warranties).
   *
   */
   /*
   * Plugin auto manages the players radio.
   *
   * The supported messages are:
   * Taking Fire, Need Assistance
   * Enemy Spotted
   * Need Backup
   * She's gonna Blow!
   * Enemy Down
   *
   * Radio calls are not executed when a
   * player is alone in his team.
   *
   * NOTE: The methods used here are not sophisticated
   * so often the auto managment can only betray
   * your position for enemy than help your teammates,
   * nevertheless the gameplay seems to be more lively :)
   *
   */
   #include <amxmod>
   #define RADIO_MESSAGES     4
   #define ENEMY_SPOTED        0
   #define IM_ON_POS                1
   #define NEED_BACKUP            2
   #define ENEMY_DOWN            3
   new Float:radiotime[33][RADIO_MESSAGES]
   new bplanter

   use_radio(id,menu[],key[]){
       engclient_cmd(id,menu)
       engclient_cmd(id,"menuselect",key)
       client_cmd(id,"slot10")
   }
   set_radio(id,Float:value){
       for(new a=0;a<RADIO_MESSAGES;++a)
           radiotime[id][a] = value
   }
   public death_event(){// ENEMY DOWN
       new attacker = read_data(1)
       new victim = read_data(2)
       new vsteam[32], ppl[32], inum
       new vteam = get_user_team(victim,vsteam,31)

       get_players(ppl,inum,"ae",vsteam) // Check if in victim team there
   is one man
       if  (inum==1)  set_radio(ppl[0],99999.0)  //  If  yes then disable
   announcment

       new Float:gametime = get_gametime()

       if ( victim && (victim < 33) && attacker &&  (attacker < 33)
            && radiotime[attacker][ENEMY_DOWN] < gametime )    {
           new asteam[32]
           new ateam = get_user_team(attacker,asteam,31)
           if  (ateam != vteam){ // If different team then announce enemy
   down
               radiotime[attacker][ENEMY_DOWN]  =  gametime + 1.0 // next
   announce can be at least 1.0 sec. later
               use_radio(attacker,"radio3","9")
           }
           get_players(ppl,inum,"ae",asteam) // Check if in attacker team
   there is one man
           if  (inum==1)set_radio(ppl[0],99999.0)  // If yes then disable
   announcment
       }

       return PLUGIN_CONTINUE
   }
   public client_connect(id){
       set_radio(id,0.0)
       return PLUGIN_CONTINUE
   }
   public spec_event(id){ // ENEMY SPOTED
       new sid = read_data(2)
       if (!sid) return PLUGIN_CONTINUE
       new yteam = get_user_team(id)
       new hteam = get_user_team(sid)
       new Float:gametime = get_gametime()
       if (yteam != hteam)    {
           if ( radiotime[id][ENEMY_SPOTED] < gametime )
               use_radio(id,"radio3","2")
           if (radiotime[id][ENEMY_SPOTED] != 99999.0)
               radiotime[id][ENEMY_SPOTED]  =  gametime  +  10.0  // next
   announce can be at least 10.0 sec. later
       }
       return PLUGIN_CONTINUE
   }
   public gonna_blow(param[]) // SHE'S GONNA BLOW! (10 sec. before exp.)
       use_radio(param[0],"radio3","7")
   public bomb_planted(){ // SHE'S GONNA BLOW!
       new Float:exptime = get_cvar_float("mp_c4timer")
       exptime -= 10.0
       if (exptime <= 0.0)
           use_radio(bplanter,"radio3","7")
       else{
           new param[2]
           param[0] = bplanter
           set_task(exptime,"gonna_blow",1234,param,1)
       }
   }
   public round_end(){
       new ppl[32], inum
       get_players(ppl,inum)
       // If less than 3 ppl then don't activate radio manager
       new Float:setto = (inum < 3) ? 9999.0 : 0.0
       for(new i=0;i<inum;++i)
           set_radio(ppl[i],setto)
       remove_task(1234)
   }
   public got_bomb(id)
       bplanter = id

   public damage_event(id){ // NEED BACKUP / TAKING FIRE, NEED ASSISTANCE
       new Float:gametime = get_gametime()
       if (radiotime[id][NEED_BACKUP] > gametime)
           return PLUGIN_CONTINUE
       new eid = get_user_attacker(id)
       if ( eid &&    (get_user_team(id) != get_user_team(eid)) ){
           radiotime[id][NEED_BACKUP] = gametime + 10.0  // next announce
   can be at least 10.0 sec. later
           if (random_num(0,100) < 50)
               use_radio(id,"radio1","6")
           else
               use_radio(id,"radio3","3")
       }
       return PLUGIN_CONTINUE
   }
   public plugin_init() {
       register_plugin("Teamplay Helper","0.2","default")
       register_event("DeathMsg","death_event","a")
       register_event("StatusValue","spec_event","be","1=2")
       register_event("TeamScore","round_end","ac")
       register_event("SendAudio",          "bomb_planted",          "a",
   "2&%!MRAD_BOMBPL")
       register_event("StatusIcon",   "got_bomb",   "be",  "1=1",  "1=2",
   "2=c4")
       register_event("Damage", "damage_event", "b", "2!0", "3=0", "4!0")
       return PLUGIN_CONTINUE
   }
