
   /* AMX Mod script.
   *
   * (c) Copyright 2002, RAV
   * This file is provided as is (no warranties).
   *
   *
   *
   * Changelog:
   *
   * V 1.10 - Initial beta test
   * V 1.11 - TimeBomb Added
   * V 1.12 - Set no clip on index
   * V 1.13 - Admin rights added
   * V 1.14 - FIXED: Dead cannot roll the dice
   * V 1.15 - Invisible added.
   * V 1.16 - Timer between dice rolls added (customizable)
   *
   * Credits:
   *
   *    Ludwig van - For writing timebomb & help with other parts.
   *
   */
   #include <amxmod>
   new BOMB_FUSE = 5        // fuse time (can be changed)
   new   BOMBKILL_RANGE   =  250  //  killing  radius  of  bomb.  (96  is
   playerheight)
   new waitTime_int = 60  // Time between allowed Dice Rolls
   new light
   new smoke
   new white
   new fire
   new Float:ejl_ff
   new IsBomb[33]
   new IsKamik[33]
   new bool:rs = false
   new bool:diceAllow = true
   new AllowRoll[33] = {1,...}
   explode(vec1[3]){
      // blast circles
      message_begin( MSG_BROADCAST,SVC_TEMPENTITY,vec1)
      write_byte( 21 )
      write_coord(vec1[0])
      write_coord(vec1[1])
      write_coord(vec1[2] + 16)
      write_coord(vec1[0])
      write_coord(vec1[1])
      write_coord(vec1[2] + 1936)
      write_short( white )
      write_byte( 0 ) // startframe
      write_byte( 0 ) // framerate
      write_byte( 2 ) // life 2
      write_byte( 20 ) // width 16
      write_byte( 0 ) // noise
      write_byte( 188 ) // r
      write_byte( 220 ) // g
      write_byte( 255 ) // b
      write_byte( 255 ) //brightness
      write_byte( 0 ) // speed
      message_end()

      //Explosion2
      message_begin( MSG_BROADCAST,SVC_TEMPENTITY)
      write_byte( 12 )
      write_coord(vec1[0])
      write_coord(vec1[1])
      write_coord(vec1[2])
      write_byte( 188 ) // byte (scale in 0.1's) 188
      write_byte( 10 ) // byte (framerate)
      message_end()
      //TE_Explosion
      message_begin( MSG_BROADCAST,SVC_TEMPENTITY,vec1)
      write_byte( 3 )
      write_coord(vec1[0])
      write_coord(vec1[1])
      write_coord(vec1[2])
      write_short( fire )
      write_byte( 60 ) // byte (scale in 0.1's) 188
      write_byte( 10 ) // byte (framerate)
      write_byte( 0 ) // byte flags
      message_end()
      //Smoke
      message_begin( MSG_BROADCAST,SVC_TEMPENTITY,vec1)
      write_byte( 5 ) // 5
      write_coord(vec1[0])
      write_coord(vec1[1])
      write_coord(vec1[2])
      write_short( smoke )
      write_byte( 10 )  // 2
      write_byte( 10 )  // 10
      message_end()
   }
   blood(vec1[3])
   {
      //LAVASPLASH
      message_begin( MSG_BROADCAST,SVC_TEMPENTITY)
      write_byte( 10 )
      write_coord(vec1[0])
      write_coord(vec1[1])
      write_coord(vec1[2])
      message_end()
   }
   lightning(vec1[3],vec2[3])
   {
      //Lightning
      message_begin( MSG_BROADCAST,SVC_TEMPENTITY)
      write_byte( 0 )
      write_coord(vec1[0])
      write_coord(vec1[1])
      write_coord(vec1[2])
      write_coord(vec2[0])
      write_coord(vec2[1])
      write_coord(vec2[2])
      write_short( light )
      write_byte( 1 ) // framestart
      write_byte( 5 ) // framerate
      write_byte( 2 ) // life
      write_byte( 20 ) // width
      write_byte( 30 ) // noise
      write_byte( 200 ) // r, g, b
      write_byte( 200 ) // r, g, b
      write_byte( 200 ) // r, g, b
      write_byte( 200 ) // brightness
      write_byte( 200 ) // speed
      message_end()
      //Sparks
      message_begin( MSG_PVS, SVC_TEMPENTITY,vec2)
      write_byte( 9 )
      write_coord( vec2[0] )
      write_coord( vec2[1] )
      write_coord( vec2[2] )
      message_end()

   }
   public amx_rolldice(id){
      if (!(get_user_flags(id)&ADMIN_SLAY)){
         client_print(id,print_console,"[AMX]  You have no access to that
   command")
         return PLUGIN_HANDLED
      }
      if (read_argc() < 2){
         new onoff[4]
         if(diceAllow == true){
             copy(onoff, 4, "ON")
      }
         else {
         copy(onoff, 4, "OFF")
         }
         client_print(id,print_console,"[AMX]  Usage: amx_rolldice < on |
   off >     Currently: %s", onoff)
         return PLUGIN_HANDLED
      }
      new arg[10]
      read_argv(1,arg,10)
      if ( (equal(arg,"on", 2)) || (equal(arg,"1", 1)) ){
         diceAllow = true
         client_print(id,print_console,"[AMX]   Roll  Dice  mode  is  now
   ON")
         client_print(0,print_chat,"[AMX] Admin has turned Roll Dice mode
   ON")
         set_hudmessage(200,  100, 0, -1.0, 0.30, 0, 6.0, 6.0, 0.5, 0.15,
   1)
         show_hudmessage(0,"ADMIN   has   ENABLED   Roll  The  Dice!^nSay
   rollthedice to gamble!")
      }else{
         diceAllow = false
         client_print(id,print_console,"[AMX]   Roll  Dice  mode  is  now
   OFF")
         client_print(0,print_chat,"[AMX] Admin has turned Roll Dice mode
   OFF")
         set_hudmessage(200,  100, 0, -1.0, 0.30, 0, 6.0, 6.0, 0.5, 0.15,
   1)
         show_hudmessage(0,"ADMIN has DISABLED Roll The Dice!!")
      }
      return PLUGIN_HANDLED
   }
   public admin_timebomb(id){
      if (!(get_user_flags(id)&ADMIN_SLAY)){
         client_print(id,print_console,"[AMX]  You have no access to that
   command")
         return PLUGIN_HANDLED
      }
      if (read_argc() < 2){
         client_print(id,print_console,"[AMX]  Usage: amx_rolldice < part
   of nick >")
         return PLUGIN_HANDLED
      }
      return PLUGIN_HANDLED
   }
   public timebomb_timer(){
      new hibomb = 100
      new maxpl = get_maxplayers()
      new a
      for(a = 0; a < maxpl; a++) {
         if ((IsBomb[a] != 0) && (IsBomb[a] < hibomb)){
            hibomb = a
         }
      }
      for(a = 1; a < maxpl; a++) {
         if (IsBomb[a] > 0){
            emit_sound(a,CHAN_ITEM,  "buttons/blip2.wav", 1.0, ATTN_NORM,
   0, PITCH_NORM)
            if (IsBomb[a] == 1){
               blowem_up(a)
            }else{
               IsBomb[a] -= 1
               if (a == hibomb){
                  new name[32]
                  get_user_name(a,name,32)
                  set_hudmessage(0,  100,  200, 0.05, 0.65, 2, 0.02, 1.0,
   0.01, 0.1, 2)
                  show_hudmessage(0,"%s     will     explode     in    %d
   seconds.",name,IsBomb[a])
                  if (IsBomb[a] == 11){
                     client_cmd(0,"spk ^"fvox/remaining^"")
                  }
                  if (IsBomb[a] < 11){
                     new temp[48]
                     num_to_word(IsBomb[a],temp,48)
                     client_cmd(0,"spk ^"fvox/%s^"",temp)
                  }
               }
               if(is_user_alive(a) == 0){
                  blowem_up(a)
               }
            }
         }
      }
   }
   public blowem_up(id){
      new bombguyfrags
      if(id == 100){
         new maxpl = get_maxplayers()
         for(new a = 0; a < maxpl; a++) {
            if ((IsBomb[a] > 0) || (IsKamik[a] == 1)){
         IsKamik[a] = 0
         IsBomb[a] = 0
         new name[32]
         get_user_name(a,name,32)
         set_user_rendering(a,kRenderFxNone,255,255,255,
   kRenderNormal,16);
         set_hudmessage(0, 100, 200, 0.05, 0.65, 2, 0.02, 1.0, 0.01, 0.1,
   2)
         show_hudmessage(0,"%s has exploded.",name)
         new origin[3]
         get_user_origin(a,origin)
         origin[2] = origin[2] - 26
         user_kill(a,1)
         explode(origin)
         }
      }
      }else{
      if (IsBomb[id] > 0){
         IsBomb[id] = 0
         IsKamik[id] = 0
         new name[32]
         new team[32]
         get_user_name(id,name,32)
         set_user_rendering(id,kRenderFxNone,255,255,255,
   kRenderNormal,16);
         set_hudmessage(0, 100, 200, 0.05, 0.65, 2, 0.02, 1.0, 0.01, 0.1,
   2)
         show_hudmessage(0,"%s has exploded.",name)
         ejl_ff = get_cvar_float("mp_friendlyfire")
         new origin[3]
         get_user_origin(id,origin)
         get_user_team(id, team , 32);
         new maxpl = get_maxplayers()
         for(new a = 1; a < maxpl; a++) {
           new origin1[3]
           new team1[32]
           get_user_origin(a,origin1)
           get_user_team(a, team1 , 32)
           if(is_user_alive(a) != 0){
         if(     !     (origin[0]-origin1[0]    >    BOMBKILL_RANGE    ||
   origin[0]-origin1[0] < - BOMBKILL_RANGE ||
                           origin[1]-origin1[1]   >   BOMBKILL_RANGE   ||
   origin[1]-origin1[1] < - BOMBKILL_RANGE ||
                           origin[2]-origin1[2]   >   BOMBKILL_RANGE   ||
   origin[2]-origin1[2] < - BOMBKILL_RANGE) ){
            if(ejl_ff == 0){
            if(!equal(team, team1, 1)){
               client_print(a,print_chat,"  You  were  to  close  to  the
   walking timebimb.")
               user_kill(a,1)
               if(a != id){
               bombguyfrags = get_user_frags(id)
               bombguyfrags +=1
               set_user_frags(id,bombguyfrags)
               }
               explode(origin1)
               }
            }
            if(ejl_ff == 1){
            if(rs == false){
               client_print(a,print_chat,"  Sorry,    the   bomb   killed
   you.")
               user_kill(a,1)
               if(!equal(team, team1, 1)){
               bombguyfrags = get_user_frags(id)
               bombguyfrags +=1
               set_user_frags(id,bombguyfrags)
               }
               if(a != id){
               explode(origin1)
               }
            }
            else {
               client_print(a,print_chat,"  Sorry,    the   bomb   killed
   you.")
               if(a == id){
               user_kill(a,1)
                           }
                        }
                     }
                  }
               }
           }
         if(ejl_ff == 0){
         client_print(id,print_chat,"  Sorry, the bomb killed you.")
         user_kill(id,1)
           }
         origin[2] = origin[2] - 26
         explode(origin)
         }
      }
   }
   public Dice_Timer(params[]) {
      new id = strtonum(params)
      if (id < 0 || id > 32)
         return PLUGIN_HANDLED
      AllowRoll[id] = 1
      return PLUGIN_HANDLED
   }
   public roll_dice(id)
   {
      if (is_user_alive(id)==0)    {
         client_print(id,print_chat,"  [AMX]  You cannot roll the dice if
   you are dead!!")
         return PLUGIN_HANDLED
           }
      if(diceAllow == false){
         client_print(id,print_chat,"[AMX]  Sorry,  roll  the dice is NOT
   enabled!")
         return PLUGIN_HANDLED
      }
      if(!AllowRoll[id]) {
         client_print(id,print_chat,"[AMX] Sorry! You recently rolled the
   dice! wait %i seconds from last roll", waitTime_int)
         return PLUGIN_HANDLED
      }
      AllowRoll[id] = 0
      new idstr[12]
      format(idstr,12,"%i",id)
      set_task(float(waitTime_int),"Dice_Timer",id,idstr,12)
      new diceroll = random_num(1,12)
      set_hudmessage(id,  100,  200, 0.05, 0.65, 2, 0.02, 4.0, 0.01, 0.1,
   2)
      if (diceroll == 1) {
         user_kill(id)
         new origin[3]
         get_user_origin(id,origin)
         origin[2] = origin[2] - 26
         new sorigin[3]
         sorigin[0] = origin[0] + 150
         sorigin[1] = origin[1] + 150
         sorigin[2] = origin[2] + 400
         blood(origin)
         explode(origin)
         emit_sound(id,CHAN_ITEM,      "weapons/headshot2.wav",      1.0,
   ATTN_NORM, 0, PITCH_NORM)
         show_hudmessage(id,"You  rolled  the  dice  and  were  killed! -
   UNLUCKY!!")
         return PLUGIN_HANDLED
         }
      if (diceroll == 2) {
         set_user_health(id,35)
         new origin[3]
         get_user_origin(id,origin)
         origin[2] = origin[2] - 26
         new sorigin[3]
         sorigin[0] = origin[0] + 150
         sorigin[1] = origin[1] + 150
         sorigin[2] = origin[2] + 400
         lightning(sorigin,origin)
         emit_sound(id,CHAN_ITEM,    "ambience/thunder_clap.wav",    1.0,
   ATTN_NORM, 0, PITCH_NORM)
         show_hudmessage(id,"You rolled the dice and now have low health!
   - UNLUCKY!!")
         return PLUGIN_HANDLED
         }
      if (diceroll == 3) {
         user_slap(id,50)
         show_hudmessage(id,"You  rolled  the  dice  and  got  slapped! -
   UNLUCKY!!")
         return PLUGIN_HANDLED
         }
      if (diceroll == 4) {
         new name[32]
         get_user_name(id,name,32)
         new origin[3]
         get_user_origin(id, origin)
         origin[2] -= 30
         set_user_origin(id, origin)
         set_hudmessage(200,  100, 0, -1.0, 0.30, 0, 6.0, 6.0, 0.5, 0.15,
   1)
         show_hudmessage(0,"%s     has    been    burried    alive!!    -
   UNLUCKY!!",name)
         client_cmd(0,"spk misc/humiliation")
         return PLUGIN_HANDLED
         }
      if (diceroll == 5) {
         new red = random_num(50,255)
         new green = random_num(50,255)
         new blue = random_num(50,255)
         set_user_rendering(id,kRenderFxGlowShell,red,green,blue,kRenderN
   ormal,16)
         show_hudmessage(id,"You  rolled  the  dice  and  you now glow! -
   UNLUCKY!!")
         return PLUGIN_HANDLED
         }
      if (diceroll == 6) {
         set_user_hitzones(id,0,192)
         show_hudmessage(id,"You  rolled  the dice and can now only shoot
   legs - UNLUCKY!!")
         return PLUGIN_HANDLED
         }
      if (diceroll == 7) {
         new player = id
         IsBomb[player] = BOMB_FUSE
         new name[32]
         get_user_name(player,name,32)
         set_user_rendering(player,kRenderFxGlowShell,           255,0,0,
   kRenderNormal,16)
         client_cmd(0,"spk  ^"vox/warning _comma _comma detonation device
   activated^"")
         client_print(0,print_chat,"%s  has  become a human timebomb, run
   for cover!!!", name)
         show_hudmessage(id,"You  rolled the dice, you are now a TIMEBOMB
   - UNLUCKY!!")
         return PLUGIN_HANDLED
         }
      if (diceroll == 8) {
         set_user_health(id,500)
         set_hudmessage(200,  100, 0, -1.0, 0.30, 0, 6.0, 6.0, 0.5, 0.15,
   1)
         show_hudmessage(id,"You are now GODLIKE with 500hp")
         client_cmd(0,"spk misc/godlike")
         return PLUGIN_HANDLED
         }
      if (diceroll == 9) {
         engclient_cmd(id,"drop")
         engclient_cmd(id,"drop")
         give_item(id,"weapon_awp")
         give_item(id,"ammo_338magnum")
         give_item(id,"ammo_338magnum")
         give_item(id,"ammo_338magnum")
         give_item(id,"weapon_deagle")
         give_item(id,"ammo_50ae")
         give_item(id,"ammo_50ae")
         give_item(id,"ammo_50ae")
         give_item(id,"ammo_50ae")
         give_item(id,"ammo_50ae")
         give_item(id,"weapon_hegrenade")
         show_hudmessage(id,"You  rolled the dice and have been given AWP
   DEAGLE and HE Grenade!")
         return PLUGIN_HANDLED
         }
      if (diceroll == 10) {
         set_user_armor(id,100)
         show_hudmessage(id,"You rolled the dice end given kevlar!")
         return PLUGIN_HANDLED
         }
      if (diceroll == 11) {
         set_user_noclip(id,1)
         show_hudmessage(id,"You rolled the dice, move where you want!")
         return PLUGIN_HANDLED
      }
      if (diceroll == 12) {
         new name[32]
         get_user_name(id,name,32)
         set_user_rendering(id,kRenderFxGlowShell,0,0,0,kRenderTransAlpha
   ,16)
         show_hudmessage(id,"You rolled the dice, you are no invisible")
         client_print(0,print_chat,"%s    is    now    invisible..   good
   luck!",name)
         return PLUGIN_HANDLED
      }
      return PLUGIN_HANDLED
   }
   public client_connect(id){
      IsBomb[id] = 0
      return PLUGIN_CONTINUE
   }
   public client_disconnect(id){
      IsBomb[id] = 0
      return PLUGIN_CONTINUE
   }
   public reset_hud(){
      server_cmd("c_unchicken")
      return PLUGIN_CONTINUE
      }
   public plugin_precache()
   {
      light = precache_model("sprites/lgtning.spr")
      precache_sound( "ambience/thunder_clap.wav")
      precache_sound( "weapons/headshot2.wav")
      smoke = precache_model("sprites/steam1.spr")
      white = precache_model("sprites/white.spr")
      fire = precache_model("sprites/explode1.spr")
      precache_sound( "buttons/blip2.wav")
      return PLUGIN_CONTINUE
   }
   public plugin_init(){
      register_plugin("Roll The Dice","1.16","RVS")
      register_clcmd("say rollthedice","roll_dice")
      register_clcmd("say rolldice","roll_dice")
      register_event("ResetHUD","reset_hud","be")
      register_clcmd("amx_rolldice","amx_rolldice",ADMIN_SLAY,"amx_rolldi
   ce :  <on |off>   turns ability to Roll Dice on and off")
      set_task(1.0,"timebomb_timer",0,"",0,"a", 9999)
      register_cvar("RVS_Rolldice", "1.16",FCVAR_SERVER)
      return PLUGIN_CONTINUE
   }
