
   /*********************************************************************
   ******
   * amx_ejl_jetpack.sma       version 2.8                 Date: 5/9/2003
   *  Author: Eric Lidman      ejlmozart@hotmail.com
   *  Alias: Ludwig van        Upgrade:
   http://lidmanmusic.com/cs/plugins.html
   *
   *  IMPORTANT:  you  need  to  aquire  and install properly the xtrafun
   module
   *   version 1.2 or better for this plugin to work. See AMX forums to
   *   get it:  http://amxmod.net/forums/viewtopic.php?t=10714
   *
   * Add a jetpack to any Half-Life mod and fly all around. Lots of cool
   *  special effects, firey blastoffs, smoke trails, sounds, etc. Thrust
   can
   *  be  vectored  to  give  better control of jetpack. Use the jump and
   move
   *  buttons  to  control thrust once your jetpack is on. Clients can to
   bind
   *  a  key  to  jetpack  or simply type it in the console to turn their
   pack on.
   *  Jetpacks can be configured to be free or require armor or money for
   *  fuel. Also, this has been set to work well for normal gravity (800)
   and
   *  low gravity (200) servers. Other gravity settings not recommended.
   *  Also,  be  careful,  jet exhaust may burn bystanders to death. This
   feature
   *  is  Friendly Fire (CS) sensitive and thus will not burn teamates if
   FF
   *  is off. This feature can be turned off. See cvars below.
   *  New:  automatic  hover  mode, hold the duck botton (usually control
   key)
   *  while  in  air  to  activate what effectively is a vertical "cruise
   control"
   *  Pressing  jump  or  pressing  duck  again exits the mode. This mode
   cannot be
   *  entered if your rate of descent is too high.
   *  New:  More  explosions.  If  you hit the ground too hard and end up
   dying
   *  with  your  jetpack  on, you blow up when you die. Also, if you get
   shot
   *  dead while your jetpack is running, you blow up when you die. Cool.
   *
   *  Jetpack Control Summary:
   *
   *   jetpack          --the  key  that  is  bound  to  jetpack turns on
   jetpack
   *   JUMP BUTTON      --propels you upward and deactivates hover mode
   *   DUCK BUTTON      --toggles hover mode
   *   FORWARD BUTTON   --propels you in the direction of your aim
   *   BACK  BUTTON      --propels  you  in the reverse direction of your
   aim
   *   MOVERIGHT BUTTON --propels you in a strafe right direction
   *   MOVELEFT BUTTON  --propels you in a strafe left direction
   *
   * PODBOT: If using my podbots controller, podbots use this plugin too.
   *
   * CLIENT COMMANDS:
   *
   *   jetpack                          --should be bound to a key, turns
   on
   *                                      jetpack if enabled and if there
   *                                      are  sufficient  funds from the
   client
   *                                      in   either   armor   or  money
   depending
   *                                      on the buytype cvar
   *   say /jetpack                     --gives clients info on setup and
   use
   *                                      of   the  jetpack  in  an  motd
   window
   *   say vote_jetpack                 --starts a vote to have jetpack
   *                                      enabled or disabled
   *
   * ADMIN COMMANDS:
   *
   *   amx_jetpacks                     --toggles jetpacks enabled or not
   *                                      Also if cvar mentioned below is
   set
   *                                      to       1,       it       also
   activates/deactivates
   *                                      plugin  "out_of_bounds.amx"  if
   you are
   *                                      using  it so that bounds limits
   are
   *                                      off when jetpack is on and vice
   versa
   *   amx_jetpacks_buytype             --toggles   jetpack  fuel  to  be
   bought
   *                                      with money or armor points
   *   amx_jetpacks_free                --sets  the  number  of seconds a
   player
   *                                      can  use  the jetpack per round
   or per
   *                                      spawn.  If  this is set to 1 or
   higher
   *                                      in  CS  it will override buying
   system.
   *   amx_jetpacks_cost <ammount>      --sets the cost of jetpack fuel
   *   amx_jetpackvote                  --toggles   on/off   ability  for
   players
   *                                      to start votes, default setting
   is on
   *   amx_jetpackvote_default          --sets  the  current  jetpackvote
   value as
   *                                      server  default  auto-refreshed
   at every
   *                                      map  change.  ADMIN_RCON  level
   admin
   *                                      required to set server default
   *   stopvote                         --stops vote in progress
   *
   * CVARS: can be set in admin.cfg, see corresponding commands for info
   *
   *   amx_luds_jetpack 1     -- 0= disable  1= enable
   *   amx_jetpack_buytype 0  -- 0= armor    1= money
   *   amx_jetpack_cost  1     --  amount  of money or armor depending on
   buytype
   *   amx_jetpack_free 0     -- for mods other than cstrike which do not
   have
   *                             money  and  armor  to use as payment for
   jetpack.
   *                             Set  the amount of jetpack seconds given
   to
   *                             each  player at spawn. If this is set to
   1 or
   *                             higher  in  CS  it  will override buying
   system.
   *   amx_jp_pl_kill  1       --  If  you are running my "out_of_bounds"
   plugin
   *                             you  may  want it disabled when you have
   the
   *                             jetpack enabled. If you want this plugin
   to
   *                             leave  "out_of_bounds"  alone,  then set
   this
   *                             cvar to 0 in your admin.cfg.
   *   amx_jetpack_atspawn  0  --  Default  is  0  to enforce a 15 second
   delay on
   *                             jetpack ignition at round start in CS so
   as
   *                             to prevent spawn massacres. Set to 1 to
   *                             ignore the delay.
   *   amx_jetpack_no_vip  1   --  default is 1 to not allow vip in CS to
   use
   *                             the jetpack. Set that cvar to 0 to allow
   *                             vip jetpack usage.
   *   amx_jetpack_exkill  1   --  this  sets  whether  the firey jetpack
   exhaust
   *                             can  kill  players  by  setting  them on
   fire.
   *                             0= disable  1= enable
   *   amx_jetpack_auto 0     -- this sets whether your clients' jetpacks
   are
   *                             automatically turned on for them.
   *                             0= disable  1= enable auto turn on
   *   amx_jetpack_autobots 1 -- this sets whether your bots jetpacks are
   *                             auto  turned on for them since they cant
   do it
   *                             themselves.  0=  disable  1= enable auto
   turn on
   *   amx_jvote_delay  180.0  --  Default  180.0  seconds. Delay between
   jetpack
   *                             votes allowed started by a non admin
   *   amx_jetpack_obeyffcvar -- if mp_friendlyfire is 1 and this cvar is
   set
   *                             to   0,  this  plugin  will  act  as  if
   friendlyfire
   *                             is off ... even if its on.
   *   amx_jetpack_tkpunish1  --  for  friendlyfire  on,  the  option  to
   punish team
   *                             killer.  Quota is from amx_jp_tkpunsish2
   cvar
   *                             options: a mix of kill,kick, and ban
   *                                0 = no action on team killer
   *                                1 = kick tker on tk quota
   *                                2 = 3 hour ban tker on quota
   *                                3 = always kill tker, kick on quota
   *                                4 = always kill tker, ban on quota
   *   amx_jetpack_tkpunish2  --   for   friendlyfire   on,  quantity  of
   teammates a
   *                             player can kill before a kick or ban can
   *                             result   depending  on  amx_jp_tkpunish1
   cvar
   *
   * CREDIT:
   *
   *   At first, I did swipe some code from Lazy's jetpack plugin to make
   this
   *   plugin,  but  when  its all said and done I pretty much did my own
   thing
   *   and  scrapped  pretty  much  everything from the original and just
   plain
   *   re-did  it  to  my liking, so there really isnt too much (any?) of
   the
   *   original  left,  except  maybe its the original inspiration. But I
   wanted
   *   to mention it anyway.
   *
   * ADDITIONAL:
   *
   *   If you have the module from SpaceDude's warcraft3 plugin (war3_ms)
   you
   *   can  make  the deahtmessages look more real, so flamethrower kills
   look
   *   like  an actual player killing another player instead of a suicide
   on the
   *   part  of the killed player. To enable this, you need to change the
   code
   *   below.  Simply change the value to 1 where it has #define use_war3
   0
   *   Its  simple, a one line change, thats it, compile and its ready to
   go.
   *
   **********************************************************************
   *****/
   /*  To get the better deathmessages. Change this one  */
   /*  line so it looks like:    #define use_war3 1      */
   #define use_war3 0
   /*********************************************************************
   ***************
   *
                *
   *  *end*  customizable section of code. other changes can be done with
   the cvars    *
   *
                *
   **********************************************************************
   **************/
   #include <amxmod>
   #include <amxmisc>
   #include <xtrafun>
   #if use_war3 == 1
   #include <war3>
   new gmsgDeathMsg
   new redundant_plug
   #endif
   new jetpack_status[33]
   new jp_switch[33]
   new jp_switch_2[33]
   new sound_sw[33]
   new hover_mode[33]
   new hover_height[33]
   new last_zvel[33]
   new jp_freecount[33]
   new jp_fuelcounter[33]
   new isburning[33]
   new gexplo
   new dexplo
   new smoke
   new exhaust
   new smoke1
   new burning
   new bool:cstrike_running
   new bool:dod_running
   new ob_pl1,ob_pl2
   new round_st
   new round_st_a
   new IsVip[33]
   new dlog = 0
   new ft_to[33]
   new tkcount[33]
   new cmd_onrope[33]
   new shutdown[33]
   new dod_team[33]
   new bot_boost[33]
   new Float:bot_boosttime[33]
   new vault_value[128]
   new votenumber = 0
   new votecontroller[33][2]
   new option[4]
   new Float:vote_ratio
   new st_vote = 0
   new totalvoters = 0
   new bool:bVoteToStop = false
   new bool:jvote_deny = false
   new bool:bJPvote = true
   new restrict_override
   #define radius 60
   public plugin_init(){
       register_plugin("Luds Jetpack","2.8","EJL")
       register_concmd("amx_jetpacks","amx_jp",ADMIN_LEVEL_H,":   toggles
   jetpacks on and off")
       register_concmd("amx_jetpacks_cost","amx_jp_c",ADMIN_LEVEL_H,":
   sets jetpack fuel cost in money or armor amount")
       register_concmd("amx_jetpacks_free","amx_jp_f",ADMIN_LEVEL_H,":
   sets jetpack fuel in seconds allowed per round, overrides buying")
       register_concmd("amx_jetpacks_buytype","amx_jp_b",ADMIN_LEVEL_H,":
   toggles jetpacks fuel buytype: armor or money")
       register_concmd("amx_jetpackvote","amx_jp_vote",ADMIN_LEVEL_H,":
   toggles ability for players to start jetpack votes on and off")
       register_concmd("amx_jetpackvote_default","amx_jp_vote_d",ADMIN_RC
   ON,": sets the current jetpackvote mode to server default")
       register_clcmd("jetpack","start_jetpack")
       register_clcmd("say /jetpack","jetpack_motd")
       register_clcmd("say","HandleSay")
       register_srvcmd("ropemissile_chk","rp_jetpack_chk")
       register_srvcmd("bot_jetpackboost","bot_jetpackboost")
       register_cvar("amx_luds_jetpack","1",FCVAR_SERVER )
       register_cvar("amx_jetpack_cost","2")
       register_cvar("amx_jetpack_free","0")
       register_cvar("amx_jetpack_buytype","0")
       register_cvar("amx_jetpack_atspawn","0")
       register_cvar("amx_jetpack_no_vip","1")
       register_cvar("amx_jetpack_exkill","1")
       register_cvar("amx_jetpack_auto","0")
       register_cvar("amx_jetpack_tkpunish1","1")
       register_cvar("amx_jetpack_tkpunish2","3")
       register_cvar("amx_jetpack_obeyffcvar","1")
       register_cvar("amx_jetpack_autobots","1")
       set_cvar_string("amx_luds_jetpack","1")
       set_cvar_string("amx_jetpack_cost","2")
       set_cvar_string("amx_jetpack_free","0")
       set_cvar_string("amx_jetpack_buytype","0")
       set_cvar_string("amx_jetpack_atspawn","0")
       set_cvar_string("amx_jetpack_no_vip","1")
       set_cvar_string("amx_jetpack_exkill","1")
       set_cvar_string("amx_jetpack_auto","0")
       set_cvar_string("amx_jetpack_tkpunish1","1")
       set_cvar_string("amx_jetpack_tkpunish2","3")
       set_cvar_string("amx_jetpack_obeyffcvar","1")
       set_cvar_string("amx_jetpack_autobots","1")
       register_concmd("stopvote","stopvote",ADMIN_MAP,"stops   vote   in
   progress")
       register_menucmd(register_menuid("Allow        Jetpacks?        ")
   ,(1<<0)|(1<<1)|(1<<2)|(1<<3),"vote_count")
       register_cvar("amx_jetpackvote_ratio","0.51")
       register_cvar("amx_vote_time","15")
       register_cvar("amx_vote_answers","1")
       register_cvar("amx_vote_delay","1")
       register_cvar("amx_last_voting","0")
       register_cvar("amx_vote_inprogress","0")
       register_cvar("amx_jvote_delay","180.0")
       set_cvar_string("amx_jvote_delay","180.0")
       register_event("DeathMsg", "DeathEvent", "a")
       register_event("Battery","vip_spawn","b","1=200")
       register_event("SendAudio","jp_spawn_delay","a","2=%!MRAD_terwin",
   "2=%!MRAD_ctwin","2=%!MRAD_rounddraw")
       register_event("TextMsg","jp_spawn_delay","a","2&#Game_C","2&#Game
   _w")
       register_event("ResetHUD", "new_spawn", "b")
       ejl_vault("READ","JETPACK_VOTE","")
       if(equal(vault_value,"OFF"))
           bJPvote = false
       else
           bJPvote = true
       register_cvar("amx_jp_pl_kill","1")
       set_task(4.0,"mapbounds_killer")
       new mod_name[32]
       get_modname(mod_name,31)
       cstrike_running = equal(mod_name,"cstrike") ? true : false
       #if use_war3 == 1
       gmsgDeathMsg = get_user_msgid("DeathMsg")
       register_event("DeathMsg", "stop_dm", "a")
       block_message(gmsgDeathMsg)
       set_task(1.0,"regulate_plugins_dm")
       register_cvar("amx_ejl_rpdm","0")
       #endif

       return PLUGIN_CONTINUE
   }
   public plugin_precache(){
       new mod_name[32]
       get_modname(mod_name,31)
       dod_running = equal(mod_name,"dod") ? true : false
       if(dod_running){
           smoke1 = precache_model("sprites/smoke.spr")
           burning = precache_model("sprites/fire.spr")
       }else{
           smoke1 = precache_model("sprites/steam1.spr")
           burning = precache_model("sprites/xfire.spr")
       }
       dexplo = precache_model("sprites/dexplo.spr")
       gexplo = precache_model("sprites/gexplo.spr")
       exhaust = precache_model("sprites/muz1.spr")
       smoke = precache_model("sprites/smoke.spr")
       precache_sound("debris/beamstart8.wav")
       precache_sound("buttons/button9.wav" )
       precache_sound("buttons/button3.wav")
       precache_sound("ambience/flameburst1.wav")
       precache_sound("ambience/burning1.wav")
       precache_sound("scientist/c1a0_sci_catscream.wav")
       precache_sound("vox/_period.wav")
       return PLUGIN_CONTINUE
   }
   public vip_spawn(id){
       new maxplayers = get_maxplayers()+1
       for (new i=1; i<=maxplayers; i++) {
           IsVip[i] = 0
       }
       if(get_cvar_num("amx_jetpack_no_vip") == 1){
           new inum
           new players[32]
           get_players(players, inum ,"c")
           if(inum > 1){
               IsVip[id] = 1
           }
       }
       return PLUGIN_CONTINUE
   }
   public DeathEvent(){
       new killer = read_data(1)
       new victim = read_data(2)
       kill_beams(victim)
       if((killer   ==   0)   &&   (jetpack_status[victim]   ==   1)   &&
   (last_zvel[victim] < -300))
           explode(victim,gexplo,40,120)
       else if((killer > 0) && (jetpack_status[victim] == 1))
           explode(victim,dexplo,35,0)
   }
   explode(id,sprite,scale,offset){
       new vec1[3]
       get_user_origin(id,vec1)
       //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)
       write_byte( 3 )
       write_coord(vec1[0])
       write_coord(vec1[1])
       write_coord(vec1[2]+offset)
       write_short( sprite )
       write_byte( scale ) // byte (scale in 0.1's) 188
       write_byte( 10 ) // byte (framerate)
       write_byte( 0 ) // byte flags
       message_end()
   }
   public first_turn_on(id[]){
       if(      ((get_cvar_num("amx_jetpack_auto")      ==      1)     ||
   (is_user_bot(id[0])) ) && (ft_to[id[0]] == 1) ){
           if(is_user_alive(id[0]) != 1 ){
               return PLUGIN_HANDLED
           }
           if(IsVip[id[0]] == 1){
               return PLUGIN_HANDLED
           }
           if(round_st == 1){
               return PLUGIN_HANDLED
           }
           client_print(id[0],print_center,"JETPACK  ON^ntype  jetpack in
   CONSOLE to turn off")
           emit_sound(id[0],   CHAN_WEAPON,  "buttons/button3.wav",  1.0,
   ATTN_NORM, 0, PITCH_NORM )
           jetpack_status[id[0]] = 1
           set_task(0.20, "jetpack_run", id[0] + 500, id, 2, "b" )
           ft_to[id[0]] = 0
           remove_task(id[0] + 533)
       }
       return PLUGIN_CONTINUE
   }
   public client_putinserver(id){
       if(  (get_cvar_num("amx_jetpack_auto")  == 1) || (is_user_bot(id))
   ){
           ft_to[id] = 1
           new Player[2]
           Player[0] = id
           set_task(5.0, "first_turn_on", id + 533, Player, 2, "b" )
       }
       return PLUGIN_CONTINUE
   }
   public client_connect(id){
       bot_boost[id] = 0
       dod_team[id] = 0
       cmd_onrope[id] = 0
       jetpack_status[id] = 0
       jp_switch[id] = 0
       sound_sw[id] = 0
       isburning[id] = 0
       votecontroller[id][1] = 0
       if(ft_to[id])
           remove_task(id+533)
       shutdown[id] = 0
       jp_freecount[id] = get_cvar_num("amx_jetpack_free")
       return PLUGIN_CONTINUE
   }
   public client_disconnect(id){
       bot_boost[id] = 0
       dod_team[id] = 0
       cmd_onrope[id] = 0
       votecontroller[id][1] = 0
       if (jetpack_status[id] == 1)
           remove_task(id+500)
       if(ft_to[id])
           remove_task(id+533)
       shutdown[id] = 0
       return PLUGIN_CONTINUE
   }
   public plugin_log(){
       new args = read_logargc()
       if(args == 2){
           new msg[32]
           read_logargv(1,msg,31)
           if(msg[6] == 'S')
               round_start()
       }
       else if(args == 3){
           new msg[32]
           read_logargv(1,msg,31)
           if(equal(msg,"joined t",8)){
               new clinfo[64],won[32],cutoff,bcount
               new classinfo[32]
               read_logargv(0,clinfo,63)
               read_logargv(2,classinfo,31)
               new tcbackw = strlen(clinfo)
               new cbackw = tcbackw
               for(new i=0;i<tcbackw;i++){
                   cbackw -= 1
                   if(cbackw > 0){
                       if(clinfo[cbackw] == '<'){
                           bcount +=1
                           if(bcount == 3){
                               copy(won,i-cutoff,clinfo[cbackw+1])
                           }
                           else if(bcount == 2)
                               cutoff = i + 2
                       }
                   }
               }
               new iwon = strtonum(won)
               new playerl = find_player("k",iwon)
               if(!playerl) return PLUGIN_CONTINUE
               if(equali(classinfo,"Axis"))
                   dod_team[playerl] = 1
               else
                   dod_team[playerl] = 2
           }
       }
       return PLUGIN_CONTINUE
   }
   round_start(){
       new maxpl = get_maxplayers()+1
       for(new k = 1; k < maxpl; k++){
           isburning[k] = 0
           new freeJ = get_cvar_num("amx_jetpack_free")
           if(freeJ > 0)
               jp_freecount[k] = freeJ
       }
   }
   public new_spawn(id){
       #if use_war3 == 1
       block_message(gmsgDeathMsg)
       #endif
       isburning[id] = 0
       new freeJ = get_cvar_num("amx_jetpack_free")
       if((!cstrike_running) || (freeJ > 0))
           jp_freecount[id] = freeJ
       return PLUGIN_CONTINUE
   }
   public mapbounds_killer(){
       if(get_cvar_num("amx_jp_pl_kill") == 0)
           return PLUGIN_CONTINUE
       new nump = get_pluginsnum()
       new filename[64],name[64],version[32],author[32],status[32]
       for(new i=0;i<nump;++i){
           get_plugin(i,filename,63,name,63,version,31,author,31,status,3
   1)
           if(equali(filename,"amx_ejl_outofbounds.amx")){
               ob_pl1 = 1
               if(get_cvar_num("amx_luds_jetpack") == 1){
                   pause("ac","amx_ejl_outofbounds.amx")
                   log_message("[AMX] Plugin: amx_ejl_outofbounds.amx has
   been deactivated since jetpack is enabled")
               }
           }
           else if(equali(filename,"out_of_bounds.amx")){
               ob_pl2 = 1
               if(get_cvar_num("amx_luds_jetpack") == 1){
                   pause("ac","out_of_bounds.amx")
                   log_message("[AMX]  Plugin: out_of_bounds.amx has been
   deactivated since jetpack is enabled")
               }
           }
       }
       return PLUGIN_CONTINUE
   }
   public roundstart_delay(){
       round_st_a = 0
       round_st = 0
       if(get_cvar_num("amx_jetpack_auto") == 1)
           client_cmd(0,"jetpack")
       if(get_cvar_num("amx_jetpack_autobots") == 1){
           new maxplayers = get_maxplayers()+1
           for (new i=1; i<=maxplayers; i++){
               if(is_user_connected(i)){
                   if( is_user_alive(i) && is_user_bot(i) )
                       start_jetpack(i)
               }
           }
       }
   }
   public jp_spawn_delay(){
       if(round_st_a == 0) {
           round_st_a = 1
           set_task(3.8,"jp_spawn_delay3")
           set_task(5.0,"jp_spawn_delay2")
           if(get_cvar_num("amx_jetpack_atspawn") == 0)
               set_task(20.0,"roundstart_delay")
           else
               set_task(5.5,"roundstart_delay")
       }
       return PLUGIN_CONTINUE
   }
   public jp_spawn_delay2(){
       round_st = 1
       new maxplayers = get_maxplayers()+1
       for (new i=1; i<=maxplayers; i++) {
           if(is_user_connected(i) == 1){
               jetpack_status[i] = 0
               remove_task(i+500)
               kill_beams(i)
               client_print(i,print_center,"Jetpack off")
               emit_sound(i,   CHAN_WEAPON,  "buttons/button9.wav",  1.0,
   ATTN_NORM, 0, PITCH_NORM )
           }
       }
       return PLUGIN_CONTINUE
   }
   public jp_spawn_delay3(){
       new maxplayers = get_maxplayers()+1
       for (new i=1; i<=maxplayers; i++) {
           if(is_user_connected(i) == 1){
               kill_beams(i)
               if(hover_mode[i] == 1){
                   hover_mode[i] = 0
                   jp_switch_2[i] = 0
                   client_print(i,print_center,"Automatic    hover   mode
   de-activated")
                   client_cmd(i, "spk fvox/alert")
                   emit_sound(i, CHAN_WEAPON, "buttons/button9.wav", 1.0,
   ATTN_NORM, 0, PITCH_NORM )
               }
           }
       }
       round_st_a = 0
       return PLUGIN_CONTINUE
   }
   public sqrt(num) {
       new div = num
       new result = 1
       while (div > result) { // end when div == result, or just below
           div = (div + result) / 2 // take mean value as new divisor
           result = num / div
       }
       return div
   }
   public make_trail(entindex){
       message_begin(MSG_BROADCAST, SVC_TEMPENTITY)
       write_byte(22)       // TE beam follow
       write_short(entindex)// ent id
       write_short(smoke)   // sprite
       write_byte(45)       //life
       write_byte(10)        //width
       write_byte(224)      //r,g,b
       write_byte(224)
       write_byte(255)
       write_byte(100)      //bright
       message_end()
   }
   public kill_beams(entindex){
       message_begin(MSG_BROADCAST, SVC_TEMPENTITY)
       write_byte(99)
       write_short(entindex)
       message_end()
   }
   public make_exhaust(vec[],ex_dir[]){
       //TE_SPRAY
       message_begin(MSG_BROADCAST,SVC_TEMPENTITY)
       write_byte (120) // Throws a shower of sprites or models
       write_coord(vec[0]) // start pos
       write_coord(vec[1])
       write_coord(vec[2])
       write_coord(ex_dir[0]) // velocity
       write_coord(ex_dir[1])
       write_coord(ex_dir[2])
       write_short (exhaust) // spr
       write_byte (4) // count
       write_byte (4) // speed
       write_byte (100) //(noise)
       write_byte (5) // (rendermode)
       message_end()
       return PLUGIN_CONTINUE
   }
   public second_exeff(ex_dir[]){
       new vec[3]
       get_user_origin(ex_dir[3],vec)
       make_exhaust(vec,ex_dir)
       if(get_cvar_num("amx_jetpack_exkill") == 1)
           check_burnzone(vec,ex_dir)
       return PLUGIN_CONTINUE
   }
   check_burnzone(vec[],aimvec[]){
       new burnvec1[3]
       burnvec1[0] = vec[0] + aimvec[0]
       burnvec1[1] = vec[1] + aimvec[1]
       burnvec1[2] = vec[2] + aimvec[2]
       new id = aimvec[3]
       new origin[3]
       new maxplayers = get_maxplayers()+1
       for (new i=1; i<=maxplayers; i++) {
           if(cvar_exists("mp_friendlyfire")){
               new ffcvar = get_cvar_num("mp_friendlyfire")
               if(    (ffcvar    ==    0)    ||   ((ffcvar   ==   1)   &&
   (get_cvar_num("amx_jetpack_obeyffcvar") == 0)) ){
                   if(dod_running){
                       if(dod_team[i] != dod_team[id]){
                           if((is_user_alive(i) == 1) && (i != id)){
                               get_user_origin(i,origin)
                               if(get_distance(origin,burnvec1) < radius)
                                   burn_victim(i,id,0)
                           }
                       }
                   }else{
                       if(get_user_team(i) != get_user_team(id)){
                           if((is_user_alive(i) == 1) && (i != id)){
                               get_user_origin(i,origin)
                               if(get_distance(origin,burnvec1) < radius)
                                   burn_victim(i,id,0)
                           }
                       }
                   }
               }else{
                   if((is_user_alive(i) == 1) && (i != id)){
                       get_user_origin(i,origin)
                       if(dod_running){
                           if(dod_team[i] == dod_team[id]){
                               if(get_distance(origin,burnvec1) < radius)
                                   burn_victim(i,id,1)
                           }else{
                               if(get_distance(origin,burnvec1) < radius)
                                   burn_victim(i,id,0)
                           }
                       }else{
                           if(get_user_team(i) == get_user_team(id)){
                               if(get_distance(origin,burnvec1) < radius)
                                   burn_victim(i,id,1)
                           }else{
                               if(get_distance(origin,burnvec1) < radius)
                                   burn_victim(i,id,0)
                           }
                       }
                   }
               }
           }else{
               if((is_user_alive(i) == 1) && (i != id)){
                   get_user_origin(i,origin)
                   if(get_distance(origin,burnvec1) < radius)
                       burn_victim(i,id,0)
               }
           }
       }
   }
   burn_victim(id,killer,tk){
       if(isburning[id] == 1)
           return PLUGIN_CONTINUE
       isburning[id] = 1
       emit_sound(id, CHAN_ITEM, "ambience/burning1.wav", 1.0, ATTN_NORM,
   0, PITCH_NORM)
       new hp,args[4]
       hp = get_user_health(id)
       if(hp > 250)
           hp = 250
       args[0] = id
       args[1] = killer
       args[2] = tk
       set_task(0.3,"on_fire",451,args,4,"a",hp / 10)
       set_task(0.7,"fire_scream",0,args,4)
       set_task(5.5,"stop_firesound",0,args,4)
       if(tk == 1){
           new namea[32]
           get_user_name(killer,namea,31)
           new teama[32]
           get_user_team(killer,teama,31)
           new players[32],pNum
           get_players(players,pNum,"e",teama)
           for(new i=0;i<pNum;i++)
               client_print(players[i],print_chat,"%s  attacked         a
   teammate",namea)
           new punish1 = get_cvar_num("amx_jetpack_tkpunish1")
           new punish2 = get_cvar_num("amx_jetpack_tkpunish2")
           if(punish1 > 2){
               user_kill(killer,0)
               set_hudmessage(255,50,50, -1.0, 0.45, 0, 0.02, 10.0, 1.01,
   1.1, 4)
               show_hudmessage(killer,"YOU   WERE  KILLED^nFOR  ATTACKING
   TEAMMATES.^nSEE THAT IT HAPPENS NO MORE!")
           }
           tkcount[killer] +=1
           if((punish1) && (tkcount[killer] > punish2 - 1)){
               if(punish1 == 1 || punish1 == 3)
                   client_cmd(killer,"echo   You  were  kicked  for  team
   killing;disconnect")
               else if(punish1 == 2 || punish1 == 4){
                   client_cmd(killer,"echo   You  were  banned  for  team
   killing")
                   new authida[16]
                   get_user_authid(killer,authida,15)

                   if (equal("4294967295",authida)){
                       new ipa[32]
                       get_user_ip(killer,ipa,31,1)
                       server_cmd("addip 180.0 %s;writeip",ipa)
                   }else{
                       server_cmd("banid 180.0 %s kick;writeid",authida)
                   }
               }
           }
       }
       return PLUGIN_CONTINUE
   }
   public on_fire(args[]){
       new hp,rx,ry,rz,forigin[3]
       new id = args[0]
       new killer = args[1]
       new tk = args[2]
       if(isburning[id] == 0)
           return PLUGIN_CONTINUE
       rx = random_num(-30,30)
       ry = random_num(-30,30)
       rz = random_num(-30,30)
       get_user_origin(id,forigin)
       //TE_SPRITE - additive sprite, plays 1 cycle
       message_begin( MSG_BROADCAST,SVC_TEMPENTITY)
       write_byte( 17 )
       write_coord(forigin[0]+rx) // coord, coord, coord (position)
       write_coord(forigin[1]+ry)
       write_coord(forigin[2]+10+rz)
       write_short( burning ) // short (sprite index)
       write_byte( 30 ) // byte (scale in 0.1's)
       write_byte( 200 ) // byte (brightness)
       message_end()
       //Smoke
       message_begin( MSG_BROADCAST,SVC_TEMPENTITY)
       write_byte( 5 )
       write_coord(forigin[0]+(rx*2)) // coord, coord, coord (position)
       write_coord(forigin[1]+(ry*2))
       write_coord(forigin[2]+100+(rz*2))
       write_short( smoke1 )// short (sprite index)
       write_byte( 60 ) // byte (scale in 0.1's)
       write_byte( 15 ) // byte (framerate)
       message_end()
       if(is_user_alive(id) == 0)
           return PLUGIN_CONTINUE
       hp = get_user_health(id)
       set_user_health(id,hp - 11)
       if(hp - 11 < 1){
           new
   namek[32],namev[32],authida[40],authidv[40],teama[32],teamv[32]
           get_user_name(id,namev,31)
           get_user_name(killer,namek,31)
           get_user_authid(id,authidv,39)
           get_user_authid(killer,authida,39)
           get_user_team(id,teamv,31)
           get_user_team(killer,teama,31)
           if(dlog)
               log_to_file("admin_logs/JP_BURN.log","%s   jetpack
   burned   %s",namek,namev)
           log_message("^"%s<%d><%s><%s>^" killed ^"%s<%d><%s><%s>^" with
   ^"Jetpack Exhaust^"",
               namek,get_user_userid(killer),authida,teama,namev,get_user
   _userid(id),authidv,teamv)
           client_print(id,print_chat,"[AMX]  You  were  killed  by  %s's
   jetpack exhaust",namek)
           client_print(killer,print_chat,"[AMX]  You killed %s with your
   jetpack exhaust",namev)
           new fr = get_user_frags(killer)
           if(tk == 1){
               client_print(killer,print_center,"You killed a teammate")
               set_user_frags(killer,fr - 1)
           }else{
               set_user_frags(killer,fr + 1)
           }
           new fr2 = get_user_frags(id)
           set_user_frags(id,fr2 + 1)
           #if use_war3 == 1
           stop_dm(killer,id,1,9876)
           #endif
           server_cmd("artificial_dm %d %d",killer,id)
       }
       return PLUGIN_CONTINUE
   }
   public fire_scream(args[]){
       emit_sound(args[0], CHAN_AUTO, "scientist/c1a0_sci_catscream.wav",
   1.0, ATTN_NORM, 0, PITCH_NORM)
       return PLUGIN_CONTINUE
   }
   public stop_firesound(args[]){
       isburning[args[0]] = 0
       emit_sound(args[0],  CHAN_ITEM, "vox/_period.wav", 1.0, ATTN_NORM,
   0, PITCH_NORM)
       return PLUGIN_CONTINUE
   }
   public amx_jp(id,level,cid){
       if (!cmd_access(id,level,cid,1))
           return PLUGIN_HANDLED
       new command[60]
       new variable[6]
       new name[32]
       get_user_name(id,name,31)
       read_argv(0,command,59)
       read_argv(1,variable,5)
       if(get_cvar_num("amx_luds_jetpack") == 1){
           set_cvar_string("amx_luds_jetpack","0")
           client_print(id,print_console,"[AMX]  %s  has  been set turned
   OFF",command)
           server_print("[AMX] %s has been set turned OFF",command)
           switch(get_cvar_num("amx_show_activity"))    {
               case  2:    client_print(0,print_chat,"ADMIN  %s: Executed
   %s OFF",name,command)
               case  1:    client_print(0,print_chat,"ADMIN:  Executed %s
   OFF",command)
           }
           if(      (get_cvar_num("amx_jp_pl_kill")      ==     1)     &&
   (get_cvar_num("sv_ninjarope") != 1) ){
               if(ob_pl1 == 1){
                   unpause("ac","amx_ejl_outofbounds.amx")
                   log_message("[AMX] Plugin: amx_ejl_outofbounds.amx has
   been re-activated since jetpack is off")
               }
               if(ob_pl2 == 1){
                   unpause("ac","out_of_bounds.amx")
                   log_message("[AMX]  Plugin: out_of_bounds.amx has been
   re-activated since jetpack is off")
               }
           }
       }else{
           set_cvar_string("amx_luds_jetpack","1")
           client_print(id,print_console,"[AMX]  %s  has  been set turned
   ON.",command)
           server_print("[AMX] %s has been set turned ON.",command)
           switch(get_cvar_num("amx_show_activity"))    {
               case  2:    client_print(0,print_chat,"ADMIN  %s: Executed
   %s ON",name,command)
               case  1:    client_print(0,print_chat,"ADMIN:  Executed %s
   ON",command)
           }
           if(get_cvar_num("amx_jp_pl_kill") == 1){
               if(ob_pl1 == 1){
                   pause("ac","amx_ejl_outofbounds.amx")
                   log_message("[AMX] Plugin: amx_ejl_outofbounds.amx has
   been deactivated since jetpack is on")
               }
               if(ob_pl2 == 1){
                   pause("ac","out_of_bounds.amx")
                   log_message("[AMX]  Plugin: out_of_bounds.amx has been
   deactivated since jetpack is on")
               }
           }
       }
       if(id != 0){
           new authid[16]
           get_user_authid(id,authid,16)
           get_user_name(id,name,32)
           log_to_file("addons/amx/admin.log","^"%s<%d><%s><>^"
   jetpacks", name,get_user_userid(id),authid)
       }
       return PLUGIN_HANDLED
   }
   public amx_jp_b(id,level,cid){
       if (!cmd_access(id,level,cid,1))
           return PLUGIN_HANDLED
       new variable[6]
       new name[32]
       get_user_name(id,name,31)
       read_argv(1,variable,5)
       if(get_cvar_num("amx_jetpack_buytype") == 1){
           set_cvar_string("amx_jetpack_buytype","0")
           client_print(id,print_console,"[AMX]  Jetpack  has been set to
   use ARMOR for fuel")
           server_print("[AMX]  Jetpack  has  been  set  to use ARMOR for
   fuel")
           switch(get_cvar_num("amx_show_activity"))    {
               case    2:    client_print(0,print_chat,"ADMIN   %s:   Set
   jetpack to use ARMOR for fuel",name)
               case  1:    client_print(0,print_chat,"ADMIN:  Set jetpack
   to use ARMOR for fuel")
           }
       }else{
           set_cvar_string("amx_jetpack_buytype","1")
           client_print(id,print_console,"[AMX]  Jetpack  has been set to
   use MONEY for fuel")
           server_print("[AMX]  Jetpack  has  been  set  to use MONEY for
   fuel")
           switch(get_cvar_num("amx_show_activity"))    {
               case    2:    client_print(0,print_chat,"ADMIN   %s:   Set
   jetpack to use MONEY for fuel",name)
               case  1:    client_print(0,print_chat,"ADMIN:  Set jetpack
   to use MONEY for fuel")
           }
       }
       if(id != 0){
           new authid[16]
           get_user_authid(id,authid,16)
           get_user_name(id,name,32)
           log_to_file("addons/amx/admin.log","^"%s<%d><%s><>^"
   jetpack_buytype", name,get_user_userid(id),authid)
       }
       return PLUGIN_HANDLED
   }
   public amx_jp_c(id,level,cid){
       if (!cmd_access(id,level,cid,1))
           return PLUGIN_HANDLED
       new command[60]
       new variable[6]
       new name[32]
       get_user_name(id,name,31)
       read_argv(0,command,59)
       read_argv(1,variable,5)
       set_cvar_string("amx_jetpack_cost",variable)
       client_print(id,print_console,"[AMX]    %s   has   been   set   to
   %s",command,variable)
       server_print("[AMX] %s has been set to %s",command,variable)
       switch(get_cvar_num("amx_show_activity"))    {
           case   2:  client_print(0,print_chat,"ADMIN  %s:  Executed  %s
   %s",name,command,variable)
           case    1:   client_print(0,print_chat,"ADMIN:   Executed   %s
   %s",command,variable)
       }
       new authid[16]
       get_user_authid(id,authid,16)
       get_user_name(id,name,32)
       log_to_file("addons/amx/admin.log","^"%s<%d><%s><>^"  jetpack_cost
   %s", name,get_user_userid(id),authid,variable)
       return PLUGIN_HANDLED
   }
   public amx_jp_f(id,level,cid){
       if (!cmd_access(id,level,cid,2))
           return PLUGIN_HANDLED
       new command[60]
       new variable[6]
       new name[32]
       get_user_name(id,name,31)
       read_argv(0,command,59)
       read_argv(1,variable,5)
       set_cvar_string("amx_jetpack_free",variable)
       client_print(id,print_console,"[AMX]    %s   has   been   set   to
   %s",command,variable)
       server_print("[AMX] %s has been set to %s",command,variable)
       switch(get_cvar_num("amx_show_activity"))    {
           case   2:  client_print(0,print_chat,"ADMIN  %s:  Executed  %s
   %s",name,command,variable)
           case    1:   client_print(0,print_chat,"ADMIN:   Executed   %s
   %s",command,variable)
       }
       new authid[16]
       get_user_authid(id,authid,16)
       get_user_name(id,name,32)
       log_to_file("addons/amx/admin.log","^"%s<%d><%s><>^"  jetpack_free
   %s", name,get_user_userid(id),authid,variable)
       return PLUGIN_HANDLED
   }
   public rp_jetpack_chk(){
       new sid[4],sstat[4]
       read_argv(1,sid,3)
       read_argv(2,sstat,3)
       cmd_onrope[strtonum(sid)] = strtonum(sstat)
       return PLUGIN_CONTINUE
   }
   reset_jp(id[]){
       hover_mode[id[0]] = 0
       jp_switch_2[id[0]] = 0
       kill_beams(id[0])
       shutdown[id[0]] = 1
       new arg[1]
       arg[0] = id[0]
       set_task(0.3,"cool_down",id[0]+566,arg,1)
       remove_task(id[0] + 500 )
       if(get_cvar_num("amx_jetpack_atspawn") == 0)
           jetpack_status[id[0]] = 0
   }
   public cool_down(id[]){
       shutdown[id[0]] = 0
       server_cmd("jetpackmissile_chk %d 0",id[0])
       return PLUGIN_CONTINUE
   }
   public bot_jetpackboost(){
       new arg1[8]
       read_argv(1,arg1,7)
       new id = strtonum(arg1)
       bot_boost[id] = 1
       bot_boosttime[id] = get_gametime()
       return PLUGIN_CONTINUE
   }
   public jetpack_run(id[]){
       if( (is_user_alive(id[0]) == 0) || (cmd_onrope[id[0]] == 1) ){
           reset_jp(id)
           return PLUGIN_HANDLED
       }
       if(get_cvar_num("amx_luds_jetpack") == 0){
           reset_jp(id)
           client_print(id[0],print_center,"Jetpack off")
           client_print(id[0],print_chat,"[AMX] Jetpacks are disabled")
           return PLUGIN_HANDLED
       }
       if(IsVip[id[0]] == 1){
           reset_jp(id)
           client_print(id[0],print_chat,  "[AMX]  Jetpack use by the vip
   is prohibited.")
           return PLUGIN_HANDLED
       }
       if(round_st == 1){
           reset_jp(id)
           if(get_cvar_num("amx_jetpack_auto") == 0)
               client_print(id[0],print_chat,  "[AMX]  Jetpack use during
   the first 15 seconds of a round is prohibited.")
           return PLUGIN_HANDLED
       }
       if(bot_boosttime[id[0]] < get_gametime() - 5.0)
           bot_boost[id[0]] = 0
       new Velocity[3]
       new jp_cost = get_cvar_num("amx_jetpack_cost")
       new freeJ = get_cvar_num("amx_jetpack_free")
       new p_armor = get_user_armor(id[0])
       new p_money = get_user_money(id[0])
       new vec[3]
       new aimvec[3]
       new velocityvec[3]
       new length
       new isKey = 0
       new boost
       new ex_dir[4]
       if((!cstrike_running) || (freeJ > 0)){
           if(jp_freecount[id[0]] < 1){
               reset_jp(id)
               emit_sound(  id[0],  CHAN_WEAPON, "debris/beamstart8.wav",
   1.0, ATTN_NORM, 0, PITCH_NORM )
               client_print(id[0],print_center,"Out of fuel.")
               return PLUGIN_HANDLED
           }
       }else{
           if(get_cvar_num("amx_jetpack_buytype") == 0){
               if(p_armor < jp_cost){
                   reset_jp(id)
                   emit_sound(             id[0],            CHAN_WEAPON,
   "debris/beamstart8.wav", 1.0, ATTN_NORM, 0, PITCH_NORM )
                   client_print(id[0],print_center,"Out   of   armor  for
   fuel")
                   return PLUGIN_HANDLED
               }
           }else{
               if(p_money < jp_cost){
                   reset_jp(id)
                   emit_sound(             id[0],            CHAN_WEAPON,
   "debris/beamstart8.wav", 1.0, ATTN_NORM, 0, PITCH_NORM )
                   client_print(id[0],print_center,"Out   of   money  for
   fuel")
                   return PLUGIN_HANDLED
               }
           }
       }
       get_user_velocity(id[0],Velocity)
       get_user_origin(id[0],vec)
       if(get_user_button(id[0]) & IN_DUCK ){
           if(jp_switch_2[id[0]] == 0){
               if(hover_mode[id[0]] == 0){
                   if(Velocity[2] < -350){
                       client_print(id[0],print_center,"Cannot      enter
   hover mode:^nrate of descent is too high")
                   }else{
                       hover_mode[id[0]] = 1
                       hover_height[id[0]] = vec[2]
                       emit_sound(id[0],                     CHAN_WEAPON,
   "buttons/button3.wav", 1.0, ATTN_NORM, 0, PITCH_NORM )
                       client_print(id[0],print_center,"Automatic   hover
   mode activated")
                   }
               }
           }else{
               hover_mode[id[0]] = 0
               client_print(id[0],print_center,"Automatic    hover   mode
   de-activated")
               emit_sound(id[0], CHAN_WEAPON, "buttons/button9.wav", 1.0,
   ATTN_NORM, 0, PITCH_NORM )
           }
       }else{
           if(hover_mode[id[0]] == 1)
               jp_switch_2[id[0]] = 1
           else
               jp_switch_2[id[0]] = 0
       }
       if(Velocity[2] != 0){
           if(get_user_button(id[0]) & IN_FORWARD ){
               new speed = 40
               isKey = 1
               if(jp_switch[id[0]] == 0){
                   make_trail(id[0])
                   jp_switch[id[0]] = 1
               }
               get_user_origin(id[0],aimvec,2)
               velocityvec[0]=aimvec[0]-vec[0]
               velocityvec[1]=aimvec[1]-vec[1]
               velocityvec[2]=aimvec[2]-vec[2]
               length=sqrt(velocityvec[0]*velocityvec[0]+velocityvec[1]*v
   elocityvec[1]+velocityvec[2]*velocityvec[2])
               velocityvec[0]=velocityvec[0]*speed/length
               velocityvec[1]=velocityvec[1]*speed/length
               velocityvec[2]=velocityvec[2]*speed/length
               Velocity[0] += velocityvec[0]
               Velocity[1] += velocityvec[1]
           }
           else if(get_user_button(id[0]) & IN_BACK ){
               new speed = 40
               isKey = 1
               if(jp_switch[id[0]] == 0){
                   make_trail(id[0])
                   jp_switch[id[0]] = 1
               }
               get_user_origin(id[0],aimvec,2)
               velocityvec[0]=aimvec[0]-vec[0]
               velocityvec[1]=aimvec[1]-vec[1]
               velocityvec[2]=aimvec[2]-vec[2]
               length=sqrt(velocityvec[0]*velocityvec[0]+velocityvec[1]*v
   elocityvec[1]+velocityvec[2]*velocityvec[2])
               velocityvec[0]=velocityvec[0]*speed/length
               velocityvec[1]=velocityvec[1]*speed/length
               velocityvec[2]=velocityvec[2]*speed/length
               Velocity[0] -= velocityvec[0]
               Velocity[1] -= velocityvec[1]
           }
           if(get_user_button(id[0]) & IN_MOVELEFT ){
               new speed = 40
               isKey = 1
               if(jp_switch[id[0]] == 0){
                   make_trail(id[0])
                   jp_switch[id[0]] = 1
               }
               get_user_origin(id[0],aimvec,2)
               velocityvec[0]=aimvec[0]-vec[0]
               velocityvec[1]=aimvec[1]-vec[1]
               velocityvec[2]=aimvec[2]-vec[2]
               length=sqrt(velocityvec[0]*velocityvec[0]+velocityvec[1]*v
   elocityvec[1]+velocityvec[2]*velocityvec[2])
               velocityvec[0]=velocityvec[0]*speed/length
               velocityvec[1]=velocityvec[1]*speed/length
               velocityvec[2]=velocityvec[2]*speed/length
               Velocity[0] += (velocityvec[1] * -1)
               Velocity[1] += velocityvec[0]
           }
           else if(get_user_button(id[0]) & IN_MOVERIGHT ){
               new speed = 40
               isKey = 1
               if(jp_switch[id[0]] == 0){
                   make_trail(id[0])
                   jp_switch[id[0]] = 1
               }
               get_user_origin(id[0],aimvec,2)
               velocityvec[0]=aimvec[0]-vec[0]
               velocityvec[1]=aimvec[1]-vec[1]
               velocityvec[2]=aimvec[2]-vec[2]
               length=sqrt(velocityvec[0]*velocityvec[0]+velocityvec[1]*v
   elocityvec[1]+velocityvec[2]*velocityvec[2])
               velocityvec[0]=velocityvec[0]*speed/length
               velocityvec[1]=velocityvec[1]*speed/length
               velocityvec[2]=velocityvec[2]*speed/length
               Velocity[0] += velocityvec[1]
               Velocity[1] += (velocityvec[0] * -1)
           }
           if(hover_mode[id[0]] == 1){
               isKey = 1
               if(jp_switch[id[0]] == 0){
                   make_trail(id[0])
                   jp_switch[id[0]] = 1
               }
               if(vec[2] < hover_height[id[0]]){
                   if(Velocity[2] < 0){
                       boost      =      ((Velocity[2]      *      -1)  +
   (hover_height[id[0]] - vec[2]))
                   }
               }

           }else{
               Velocity[2] += velocityvec[2]
           }
           if(get_user_button(id[0]) & IN_JUMP || bot_boost[id[0]]){
               if(hover_mode[id[0]] == 0){
                   isKey = 1
                   if(jp_switch[id[0]] == 0){
                       make_trail(id[0])
                       jp_switch[id[0]] = 1
                   }
                   if(get_cvar_num("sv_gravity") < 800)
                       boost = 75
                   else
                       boost = 210
               }else{
                   if(hover_mode[id[0]] == 1){
                       hover_mode[id[0]] = 0
                       jp_switch_2[id[0]] = 0
                       client_print(id[0],print_center,"Automatic   hover
   mode de-activated")
                   }
               }
           }
           Velocity[2] += boost
           if(isKey == 1){
               if((!cstrike_running) || (freeJ > 0)){
                   if(jp_fuelcounter[id[0]] > 4){
                       jp_fuelcounter[id[0]] = 0
                       jp_freecount[id[0]] -= 1
                       client_print(id[0],print_center,"Jetpack      fuel
   remaining %d^n^n^n",jp_freecount[id[0]])
                   }
                   jp_fuelcounter[id[0]] += 1
               }else{
                   if(get_cvar_num("amx_jetpack_buytype") == 0)
                       set_user_armor(id[0],p_armor                     -
   jp_cost)
                   else
                       set_user_money(id[0],p_money - jp_cost)
               }
           }
           set_user_velocity(id[0], Velocity)
       }
       if(isKey == 0){
           if(jp_switch[id[0]] == 1){
               shutdown[id[0]] = 1
               new arg[1]
               arg[0] = id[0]
               set_task(0.3,"cool_down",id[0]+566,arg,1)
               kill_beams(id[0])
               jp_switch[id[0]] = 0
               emit_sound(  id[0],  CHAN_WEAPON, "debris/beamstart8.wav",
   1.0, ATTN_NORM, 0, PITCH_NORM )
           }
       }else{
           ex_dir[0] = velocityvec[0] * -1
           ex_dir[1] = velocityvec[1] * -1
           ex_dir[2] = (velocityvec[2] + boost) * -1
           ex_dir[3] = id[0]
           make_exhaust(vec,ex_dir)
           set_task(0.1,"second_exeff",0,ex_dir,4)
           if(sound_sw[id[0]] == 1){
               sound_sw[id[0]] = 0
               emit_sound(id[0], CHAN_WEAPON, "ambience/flameburst1.wav",
   1.0, ATTN_NORM, 0, PITCH_NORM)
           }else{
               sound_sw[id[0]] = 1
               emit_sound(id[0],  CHAN_BODY,  "ambience/flameburst1.wav",
   1.0, ATTN_NORM, 0, PITCH_NORM)
           }
           if(shutdown[id[0]] == 1)
               remove_task(566+id[0])
           server_cmd("jetpackmissile_chk %d 1",id[0])
       }
       last_zvel[id[0]] = Velocity[2]
       return PLUGIN_CONTINUE
   }
   public start_jetpack(id){
       if(get_cvar_num("amx_luds_jetpack") == 0){
           client_print(id,print_chat,"[AMX] Jetpacks are disabled")
           return PLUGIN_HANDLED
       }
       new Player[2]
       Player[0] = id
       if(jetpack_status[id] == 1){
           new args[2]
           args[0] = id
           reset_jp(args)
           jetpack_status[id] = 0
           remove_task(id + 500 )
           client_print(id,print_center,"Jetpack off")
           emit_sound(id,    CHAN_WEAPON,   "buttons/button9.wav",   1.0,
   ATTN_NORM, 0, PITCH_NORM )
           return PLUGIN_HANDLED
       }else{
           if(is_user_alive(id) != 1 ){
               client_print(id,print_center,"You  must  be  alive  to use
   this")
               return PLUGIN_HANDLED
           }
           if(IsVip[id] == 1){
               client_print(id,print_chat, "[AMX]  Jetpack use by the vip
   is prohibited.")
               return PLUGIN_HANDLED
           }
           if(round_st == 1){
               client_print(id,print_chat, "[AMX]  Jetpack use during the
   first 15 seconds of a round is prohibited.")
               return PLUGIN_HANDLED
           }
           if(get_cvar_num("amx_jetpack_auto") == 0)
               client_print(id,print_center,"Jetpack on")
           else
               client_print(id,print_center,"JETPACK  ON^ntype jetpack in
   CONSOLE to turn off")
           emit_sound(id,    CHAN_WEAPON,   "buttons/button3.wav",   1.0,
   ATTN_NORM, 0, PITCH_NORM )
           jetpack_status[id] = 1
           set_task(0.20, "jetpack_run", id + 500, Player, 2, "b" )
       }
       return PLUGIN_HANDLED
   }
   public jetpack_motd(id){
       new hk_motd[1300]
       new temp[768]
       temp = "Bind a key to jetpack. Go to your console,^n\
                   choose a key for turning on your jetpack. Lets say^n\
               we want to use z. Do this in console:^n^n\
               bind z jetpack^n^n\
               Enter that and now whenever you press the z key,^n\
                     it  switches  your  jetpack  on  and  off. If you do
   not^n"
       add(hk_motd,1299,temp)
       temp = "want to bind a key, you may simply enter: jetpack^n\
               in the console.^n^n\
               Once the jetpack is on, you may use it by pressing^n\
               your jump button, once in the air, you can use the^n\
               the move buttons plus the jump button to control^n"
       add(hk_motd,1299,temp)
       temp = "thrust direction. The duck botton toggles an auto-^n\
               matic hover mode. Careful, jetpack exhaust can burn^n\
               nearby players. Jetpack may be set by admin to^n\
               be free or use arour or money in the ammount they^n\
               set so as to limit your fuel."
       add(hk_motd,1299,temp)
       show_motd(id,hk_motd,"Jetpack Help:")
       return PLUGIN_CONTINUE
   }
   public HandleSay(id) {
       new Speech[192]
       read_args(Speech,192)
       remove_quotes(Speech)
       if (equal(Speech, "vote_jetpack")) {
           if (restrict_override == 1) {
               client_print(id,print_chat,"[AMX]   Jetpack   restrictions
   cannot be changed. Override is on.")
               return PLUGIN_HANDLED
           }
           JPVote(id)
       }
       else if( (restrict_override == 0) && (bJPvote == true) ){
           if(  (containi(Speech,  "jet")  !=  -1)  ||  (containi(Speech,
   "fly") != -1) ){
               if(get_cvar_num("amx_luds_jetpack") == 1){
                   client_print(id,print_chat,    "[AMX]  Jetpacks    are
   enabled. To change say vote_jetpack     For help say /jetpack")
               }else{
                   client_print(id,print_chat,    "[AMX]  Jetpacks    are
   disabled. To change say vote_jetpack     For help say /jetpack")
               }
           }
       }
       return PLUGIN_CONTINUE
   }
   public amx_jp_vote(id,level,cid){
       if (!cmd_access(id,level,cid,1))
           return PLUGIN_HANDLED
       if(bJPvote == false) {
           bJPvote = true
           client_print(0,print_chat,"[AMX]  Admin has allowed players to
   initiate vote_jetpack")
           console_print(id,"[AMX]  You  have allowed players to initiate
   vote_jetpack")
       }else {
           bJPvote = false
           client_print(0,print_chat,"[AMX]  Admin  has forbidden players
   to initiate vote_jetpack")
           console_print(id,"[AMX]  You   have   forbidden   players   to
   initiate vote_jetpack")
       }
       if(id != 0){
       new authid[16],name[32]
       get_user_authid(id,authid,16)
       get_user_name(id,name,32)
       log_to_file("addons/amx/admin.log","^"%s<%d><%s><>^"
   jetpackvote_mode",
           name,get_user_userid(id),authid)
       }
       return PLUGIN_HANDLED
   }
   public amx_jp_vote_d(id,level,cid){
       if (!cmd_access(id,level,cid,1))
           return PLUGIN_HANDLED
       if(bJPvote == false){
           ejl_vault("WRITE","JETPACK_VOTE","OFF")
           console_print(id,"[AMX]      Player      initiated     jetpack
   voting  OFF   is now the default.")
       }else{
           ejl_vault("WRITE","JETPACK_VOTE","ON")
           console_print(id,"[AMX]      Player      initiated     jetpack
   voting  ON    is now the default.")
       }
       if(id != 0){
       new authid[16],name[32]
       get_user_authid(id,authid,16)
       get_user_name(id,name,32)
       log_to_file("addons/amx/admin.log","^"%s<%d><%s><>^"
   jetpackvote_mode_d",
           name,get_user_userid(id),authid)
       }
       return PLUGIN_HANDLED
   }
   public JPVote(id) {
       if (round_st == 1){
           client_print(id,print_chat,"[AMX]   Jetpack  votes  cannot  be
   started during jetpack spawn delay.")
           return PLUGIN_HANDLED
       }
       if( (jvote_deny == true) && (!(get_user_flags(id)&ADMIN_MAP)) ){
           client_print(id,print_chat,"[AMX]  We just had a jetpack vote.
   Wait a little longer.")
           return PLUGIN_HANDLED
       }
       if( (bJPvote == false) && (!(get_user_flags(id)&ADMIN_MAP)) ){
           client_print(id,print_chat,"[AMX]  Server  is set so that only
   admins can start this vote.")
           return PLUGIN_HANDLED
       }
       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 inprogress[32]
       get_cvar_string("amx_vote_inprogress",inprogress,32)
       if(equal(inprogress, "0",1)){
       new menu_msg[256]
       new keys
       if(cstrike_running)
           format(menu_msg,256,"\yAllow  Jetpacks?  \w^n^n1.  Yes, I want
   to fly!^n2.  No, jetpacks are stupid!")
       else
           format(menu_msg,256,"Allow  Jetpacks?  ^n^n1.  Yes,  I want to
   fly!^n2.  No, jetpacks are stupid!")
       keys = (1<<0)|(1<<1)
       new authid[16],name[32]
       get_user_authid(id,authid,16)
       get_user_name(id,name,32)
       log_to_file("addons/amx/admin.log","^"%s<%d><%s><>^" jetpack",
           name,get_user_userid(id),authid)
       new Float:vote_time = get_cvar_float("amx_vote_time") + 2.0
       set_cvar_float("amx_last_voting",  get_gametime() + vote_time )
       vote_ratio = get_cvar_float("amx_jetpackvote_ratio")
       for(new a = 0; a < 33; a++){
           votecontroller[a][1] = 0
       }
       votenumber++
       set_cvar_string("amx_vote_inprogress","1")
       ejl_vault("WRITE","CURRENT_VOTE","JETPACKVOTE")
       bVoteToStop = true
       totalvoters = 0
       new Team[33]
       new maxpl = get_maxplayers()+1
       for(new k = 1; k < maxpl; k++){
           if(!is_user_bot(k)){
               get_user_team(k,Team,33)
               if(!((equali(Team,"UNAS",4)) || (equali(Team,"SPEC",4)) ||
   (get_user_time(k)== 0) )){
                   show_menu(k,keys,menu_msg,floatround(vote_time))
                   totalvoters++
               }
           }
       }
       set_task(vote_time,"HandleJPVote")
       client_print(id,print_console,"[AMX] Voting has started...")
       for(new j = 0; j < 4;++j) option[j] = 0
       }else{
       client_print(id,print_chat,"[AMX] Voting not allowed yet.")
       }
       return PLUGIN_HANDLED
   }
   public HandleJPVote() {
       set_hudmessage(63,187,239,  -1.0,  0.70, 2, 0.02, 10.0, 0.01, 0.1,
   2)
       jvote_deny = true
       set_task(get_cvar_float("amx_jvote_delay"),"jetpack_vote_deny")
       set_cvar_string("amx_vote_inprogress","0")
       ejl_vault("WRITE","CURRENT_VOTE","NULL")
       bVoteToStop = false
       for(new a = 0; a < 33; a++){
           votecontroller[a][1] = 0
       }
       if(st_vote == 1){
           st_vote = 0
           client_print(0,print_chat,"[AMX]  Voting           sucessfully
   stopped.")
           return PLUGIN_HANDLED
       }
       new best = 0
       new best_count = 0
       for(new a = 0; a < 4; ++a) {
           if (option[a] > best_count){
               best_count = option[a]
               best = a
           }
       }
       new inum = totalvoters
       new  Float:result_v = inum ? (float(option[best]) / float(inum)) :
   0.0
       if (result_v >= vote_ratio) {
           if(best == 0){
               client_print(0,print_chat,"[AMX]   Voting  over  ....  Use
   Jetpack wins.")
               if(get_cvar_num("amx_luds_jetpack") == 1){
                   show_hudmessage(0,"Vote   over.^nJetpack   will   stay
   enabled.^n^n%d  votes  for  Jetpack ON^n%d votes for Jetpack OFF^n^n%d
   Total eligible voters",
                   option[0],option[1],totalvoters)
               } else {
                   if (round_st == 1){
                       client_print(0,print_chat,"[AMX]    Jetpack   vote
   wins.  Full  results jetpack enable delayed till after roundstart time
   is clear.")
                       set_task(15.0,"jetpack_vote_exec")
                   }else{
                       set_task(0.5,"jetpack_vote_exec")
                   }
               }
               log_to_file("addons/amx/admin.log","World        triggered
   ^"voting_success^"   (needed   ^"%.2f^")   (ratio   ^"%.2f^")  (result
   ^"jetpack^")",
                   vote_ratio,result_v)
           }else {
               client_print(0,print_chat,"[AMX]   Voting   over  ....  No
   Jetpacks.")
               if(get_cvar_num("amx_luds_jetpack") == 0){
                   show_hudmessage(0,"Vote   over.^nJetpack   will   stay
   disabled.^n^n%d  votes  for Jetpack ON^n%d votes for Jetpack OFF^n^n%d
   Total eligible voters",
                   option[0],option[1],totalvoters)
               } else {
                   show_hudmessage(0,"Vote  over.^nJetpack loses, no more
   flying.^n^n%d  votes  for  Jetpack  ON^n%d votes for Jetpack OFF^n^n%d
   Total eligible voters",
                   option[0],option[1],totalvoters)
                   set_cvar_string("amx_luds_jetpack","0")
                   if(    (get_cvar_num("amx_jp_pl_kill")    ==   1)   &&
   (get_cvar_num("sv_ninjarope") != 1) ){
                       if(ob_pl1 == 1){
                           unpause("ac","amx_ejl_outofbounds.amx")
                           log_message("[AMX]                     Plugin:
   amx_ejl_outofbounds.amx has been re-activated since jetpack is off")
                       }
                       if(ob_pl2 == 1){
                           unpause("ac","out_of_bounds.amx")
                           log_message("[AMX]  Plugin:  out_of_bounds.amx
   has been re-activated since jetpack is off")
                       }
                   }
               }
               log_to_file("addons/amx/admin.log","World        triggered
   ^"voting_failure^" (needed ^"%.2f^") (ratio ^"%.2f^")",
                   vote_ratio,result_v)
           }
       }else{
           client_print(0,print_chat,"[AMX] Voting for jetpacks failed...
   No clear majority.")
       }
       return PLUGIN_HANDLED
   }
   public jetpack_vote_exec(){
       set_hudmessage(63,187,239,  -1.0,  0.70, 2, 0.02, 10.0, 0.01, 0.1,
   2)
       show_hudmessage(0,"Vote over.^nUse Jetpacks wins. Blast off!^n^n%d
   votes  for Jetpacks ON^n%d votes for Jetpacks OFF^n^n%d Total eligible
   voters",
       option[0],option[1],totalvoters)
       set_cvar_string("amx_luds_jetpack","1")
       if(get_cvar_num("amx_jp_pl_kill") == 1){
           if(ob_pl1 == 1){
               pause("ac","amx_ejl_outofbounds.amx")
               log_message("[AMX]   Plugin:  amx_ejl_outofbounds.amx  has
   been deactivated since jetpack is on")
           }
           if(ob_pl2 == 1){
               pause("ac","out_of_bounds.amx")
               log_message("[AMX]   Plugin:  out_of_bounds.amx  has  been
   deactivated since jetpack is on")
           }
       }
       return PLUGIN_CONTINUE
   }
   public vote_count(id,key)
   {
       ejl_vault("READ","CURRENT_VOTE","")
       if(equal(vault_value,"JETPACKVOTE")){
       new name[32]
       get_user_name(id,name,32)
       if(votenumber != votecontroller[id][0]){
           votecontroller[id][0] = votenumber
           if (get_cvar_float("amx_vote_answers")) {
               client_print(0,print_chat,"[AMX]  %s  voted  for  option #
   %d",name,key+1)
           }
           option[key] += 1
       }else{
           votecontroller[id][1] +=1
       }
       }else{
           return PLUGIN_CONTINUE
       }
       return PLUGIN_HANDLED
   }
   public stopvote(id,level,cid){
       if (!cmd_access(id,level,cid,1))
           return PLUGIN_HANDLED
       if(bVoteToStop == true){
           new name[32]
           get_user_name(id,name,32)
           st_vote = 1
           client_print(id,print_console,"[AMX]  ADMIN   !!!  Ignore  the
   unknown command message -- its ok")
           client_print(0,print_chat,"[AMX]  %s  has disabled the vote in
   progress.",name)
       }
       return PLUGIN_CONTINUE
   }
   public jetpack_vote_deny(){
       jvote_deny = false
       return PLUGIN_CONTINUE
   }
   #if use_war3 == 1
   public stop_dm(id,tid,tbody,num){
       if(num == 9876){
           if (tbody == 1){
               message_begin( MSG_ALL, gmsgDeathMsg,{0,0,0},0)
               write_byte(id)
               write_byte(tid)
               write_string(" jetpack exhaust")
               message_end()
           }else{
               message_begin( MSG_ALL, gmsgDeathMsg,{0,0,0},0)
               write_byte(id)
               write_byte(tid)
               write_byte(0)
               write_string(" jetpack exhaust")
               message_end()
           }
       }else{
           if(redundant_plug == 0){
               new killer_id = read_data(1)
               new victim_id = read_data(2)
               new headshot = read_data(3)
               new weaponname[20]
               if(cstrike_running)
                   read_data(4,weaponname,31)
               else
                   read_data(3,weaponname,31)
               new weapon
               get_user_attacker(victim_id,weapon)

               if     (!(killer_id==victim_id     &&     !headshot     &&
   equal(weaponname,"world"))){
                   message_begin( MSG_ALL, gmsgDeathMsg,{0,0,0},0)
                   write_byte(killer_id)
                   write_byte(victim_id)
                   write_byte(headshot)
                   write_string(weaponname)
                   message_end()
               }
           }
       }
       return PLUGIN_HANDLED
   }
   public regulate_plugins_dm(){
       new nump = get_pluginsnum()
       new filename[64],name[64],version[32],author[32],status[32]
       for(new i=0;i<nump;++i){
           get_plugin(i,filename,63,name,63,version,31,author,31,status,3
   1)
           if(equali(filename,"warcraft3.amx")){
               set_cvar_num("amx_ejl_rpdm",1)
               redundant_plug = 1
           }
       }
       for(new i=0;i<nump;++i){
           get_plugin(i,filename,63,name,63,version,31,author,31,status,3
   1)
           if(get_cvar_num("amx_ejl_rpdm")){
               if(     (equali(filename,"amx_ejl_laserweapon.amx"))    &&
   (strtonum(version[0]) > 1) )
                   redundant_plug = 1
               else     if(     (equali(filename,"laser_guns.amx"))    &&
   (strtonum(version[0]) > 1) )
                   redundant_plug = 1
               else   if(   (equali(filename,"amx_ejl_missiles.amx"))  &&
   (strtonum(version[0]) > 1) )
                   redundant_plug = 1
               else     if(    (equali(filename,"cs_missiles.amx"))    &&
   (strtonum(version[0]) > 1) )
                   redundant_plug = 1
               else  if( (equali(filename,"amx_ejl_flamethrower.amx")) &&
   (strtonum(version[0]) > 4) )
                   redundant_plug = 1
               else   if(   (equali(filename,"cs_flamethrower.amx"))   &&
   (strtonum(version[0]) > 4) )
                   redundant_plug = 1
               else   if(   (equali(filename,"amx_ejl_timebomb.amx"))  &&
   (strtonum(version[0]) > 2) )
                   redundant_plug = 1
               else      if(     (equali(filename,"kamikaze.amx"))     &&
   (strtonum(version[0]) > 2) )
                   redundant_plug = 1
           }
       }
       set_cvar_num("amx_ejl_rpdm",1)
       set_task(1.0,"regulate_plugins_rs")
       return PLUGIN_CONTINUE
   }
   public regulate_plugins_rs(){
       set_cvar_num("amx_ejl_rpdm",0)
       return PLUGIN_CONTINUE
   }
   #endif
   public ejl_vault(rw[],key[],value[]){
       new data[192]
       new stxtsize = 0
       new line = 0
       new skip = 0
       new vkey[64]
       new vvalue[128]
       new vaultwrite[192]
       if(equal(rw,"READ")){
           if(file_exists("addons/amx/ejl_vault.ini") == 1){
               copy(vault_value,128,"")
               while((line=read_file("addons/amx/ejl_vault.ini",line,data
   ,192,stxtsize))!=0){
                   parse(data,vkey,64,vvalue,128)
                   if(equal(vkey,key)){
                       copy(vault_value,128,vvalue)
                   }
               }
           }else{
               write_file("addons/amx/ejl_vault.ini",  "****  Plugins use
   to store values -- immune to crashes and map changes ****", 0)
           }
       }
       else if(equal(rw,"WRITE")){
           if(file_exists("addons/amx/ejl_vault.ini") == 1){
               format(vaultwrite,192,"%s %s",key,value)
               while((line=read_file("addons/amx/ejl_vault.ini",line,data
   ,192,stxtsize))!=0){
                   parse(data,vkey,64,vvalue,128)
                   if(skip == 0){
                       if( (equal(data,"")) || (equal(vkey,key)) ){
                           skip = 1
                           write_file("addons/amx/ejl_vault.ini",vaultwri
   te,line-1)
                       }
                   }
                   else if(equal(vkey,key)){
                       write_file("addons/amx/ejl_vault.ini","",line-1)
                   }
               }
               if(skip == 0){
                   write_file("addons/amx/ejl_vault.ini",vaultwrite,-1)
               }
           }
       }
       return PLUGIN_CONTINUE
   }
