
   /* AMX Mod script.
   *
   * (c) Copyright 2003, OLO
   * This file is provided as is (no warranties).
   *
   * Plugin to enable by menu from Stats Settings Plugin.
   */
   #define STS_CHNL     6
   #define STS_FLAG10 10 //Bomb exploded
   #define STS_FLAG11 11 //Bomb planting
   #define STS_FLAG12 12 //Bomb defusing
   #define STS_FLAG13 13 //Bomb planted
   #define STS_FLAG14 14 //Bomb defused
   #define STS_FLAG15 15 //Bomb failed to defuse
   #define STS_FLAG16 16 //Bomb pickup
   #define STS_FLAG17 17 //Bomb droped
   #define STS_FLAG18 18 //Bomb countdown (voice)
   #define STS_FLAG19 19 //Bomb countdown (defuser)
   #define STS_FLAG20 20 //Bombsite reached
   #include <amxmod>
   new planter
   new defuser
   new c4timer
   new defusing
   new Float:last_omg
   new Float:last_plan
   public plugin_init(){
       register_plugin("Bomb Events","0.9.4","default")
       server_cmd("amx_addoption        ^"Bomb        exploded^"       %d
   %d",STS_CHNL,STS_FLAG10)
       server_cmd("amx_addoption        ^"Bomb        planting^"       %d
   %d",STS_CHNL,STS_FLAG11)
       server_cmd("amx_addoption        ^"Bomb        defusing^"       %d
   %d",STS_CHNL,STS_FLAG12)
       server_cmd("amx_addoption        ^"Bomb        planted^"        %d
   %d",STS_CHNL,STS_FLAG13)
       server_cmd("amx_addoption        ^"Bomb        defused^"        %d
   %d",STS_CHNL,STS_FLAG14)
       server_cmd("amx_addoption    ^"Bomb    failed   to   defuse^"   %d
   %d",STS_CHNL,STS_FLAG15)
       server_cmd("amx_addoption         ^"Bomb        pickup^"        %d
   %d",STS_CHNL,STS_FLAG16)
       server_cmd("amx_addoption         ^"Bomb        droped^"        %d
   %d",STS_CHNL,STS_FLAG17)
       server_cmd("amx_addoption    ^"Bomb    countdown    (voice)^"   %d
   %d",STS_CHNL,STS_FLAG18)
       server_cmd("amx_addoption    ^"Bomb   countdown   (defuser)^"   %d
   %d",STS_CHNL,STS_FLAG19)
       server_cmd("amx_addoption       ^"Bombsite       reached^"      %d
   %d",STS_CHNL,STS_FLAG20)
       new mapname[4]
       get_mapname(mapname,3)
       if (!equali(mapname,"de_",3))    {
           pause("a") /* pause on not de_ maps */
           return PLUGIN_CONTINUE
       }

       register_event("StatusIcon",   "got_bomb",   "be",  "1=1",  "1=2",
   "2=c4")
       register_event("SendAudio",          "bomb_planted",          "a",
   "2&%!MRAD_BOMBPL")
       register_event("SendAudio",          "bomb_defused",          "a",
   "2&%!MRAD_BOMBDEF")
       register_event("TextMsg", "bomb_failure", "a", "2&#Target_B")
       register_event("BarTime", "bdef_g", "be", "1=10", "1=5","1=3")
       register_event("BarTime", "bdef_l", "be", "1=0")
       register_event("TextMsg", "bomb_pickup", "bc", "2&#Got_bomb")
       register_event("TextMsg", "bomb_drop", "bc", "2&#Game_bomb_d")
       register_event("SendAudio",           "disable_c4",           "a",
   "2&%!MRAD_terwin","2&%!MRAD_ctwin","2&%!MRAD_rounddraw")
       register_event("TextMsg","disable_c4","a","2&#Game_C","2&#Game_w")

       return PLUGIN_CONTINUE
   }
   public got_bomb(id){
       planter = id
       defuser = defusing = 0
       if      (      (get_user_flags(0,STS_CHNL)&(1<<STS_FLAG20))     &&
   read_data(1)==2 && last_omg<get_gametime()){
           last_omg = get_gametime() + 15.0
           new name[32]
           get_user_name(planter, name , 31)
           set_hudmessage(200,  100,  0,  -1.0,  0.30,  0, 6.0, 6.0, 0.5,
   0.15, 1)
           show_hudmessage(0,"Omg! %s reached the target!",name)
       }
   }
   public bdef_g(id){
       if (read_data(1) == 3){
           if     (    (get_user_flags(0,STS_CHNL)&(1<<STS_FLAG11))    &&
   last_plan<get_gametime() ){
               last_plan = get_gametime() + 15.0
               new name[32]
               set_hudmessage(200,  100, 0, -1.0, 0.30, 0, 6.0, 6.0, 0.5,
   0.15, 1)
               get_user_name(planter, name , 31)
               show_hudmessage(0,"%s is planting the bomb!",name)
           }
       }
       else {
           defuser = defusing = id
           if     (    (get_user_flags(0,STS_CHNL)&(1<<STS_FLAG12))    &&
   last_plan<get_gametime()){
               last_plan = get_gametime() + 15.0
               new name[32]
               set_hudmessage(200,  100, 0, -1.0, 0.30, 0, 6.0, 6.0, 0.5,
   0.15, 1)
               get_user_name(defusing, name , 31)
               show_hudmessage(0,"%s is defusing the bomb...",name)
           }
       }
   }
   public bdef_l(id)
       defusing = 0
   public disable_c4(){
       c4timer = 0
       last_plan = 0.0
       last_omg = 0.0
       remove_task(8038)
   }
   public bomb_planted(){
       if (!(get_user_flags(0,STS_CHNL)&(1<<STS_FLAG13))) return
       new name[32]
       get_user_name(planter, name , 31)
       set_hudmessage(200, 100, 0, -1.0, 0.30, 0, 6.0, 6.0, 0.5, 0.15, 1)
       show_hudmessage(0,"%s set us up the bomb!!!",name)
       c4timer = get_cvar_num("mp_c4timer") - 2
       set_task(1.0,"bomb_c",8038,"",0,"b")
       last_plan = 0.0
   }
   public bomb_c(){
       if (--c4timer > 0){
           new mode = get_user_flags(0,STS_CHNL)
           if (mode & (1<<STS_FLAG18)) {
               if (c4timer == 30 || c4timer == 20){
                   new temp[48]
                   num_to_word(c4timer,temp,47)
                   client_cmd(0,"spk      ^"vox/%s      seconds     until
   explosion^"",temp)
               }
               else if (c4timer < 11){
                   new temp[48]
                   num_to_word(c4timer,temp,47)
                   client_cmd(0,"spk ^"vox/%s^"",temp)
               }
           }
           if      ((mode     &     (1<<STS_FLAG19))     &&     defusing)
   client_print(defusing,print_center,"%d",c4timer)
       }
       else{
           remove_task(8038)
       }
   }
   public bomb_defused(){
       if (!(get_user_flags(0,STS_CHNL)&(1<<STS_FLAG14))) return
       new name[32]
       get_user_name(defuser, name , 31)
       set_hudmessage(200, 100, 0, -1.0, 0.30, 0, 6.0, 6.0, 0.5, 0.15, 1)
       show_hudmessage(0,"%s defused the bomb!",name)
       disable_c4()
   }
   public bomb_failure(){
       if  (!(get_user_flags(0,STS_CHNL)&(1<<STS_FLAG15))  ||  !defuser )
   return
       new name[32]
       get_user_name(defuser, name , 31)
       set_hudmessage(200, 100, 0, -1.0, 0.30, 0, 6.0, 6.0, 0.5, 0.15, 1)
       show_hudmessage(0,"%s  failed to defuse the bomb...",name)
   }
   public bomb_pickup(id){
       if (!(get_user_flags(0,STS_CHNL)&(1<<STS_FLAG16))) return
       new name[32]
       get_user_name(id, name , 31)
       set_hudmessage(200, 100, 0, -1.0, 0.30, 0, 6.0, 6.0, 0.5, 0.15, 1)
       show_hudmessage(0,"%s pick up the bomb...",name)
   }
   public bomb_drop(){
       if (!(get_user_flags(0,STS_CHNL)&(1<<STS_FLAG17))) return
       new name[32]
       get_user_name(planter, name , 31)
       set_hudmessage(200, 100, 0, -1.0, 0.30, 0, 6.0, 6.0, 0.5, 0.15, 1)
       show_hudmessage(0,"%s dropped the bomb!!!",name)
   }
