
   /* AMX Mod Script
   *
   * Jetpack
   *
   * 2003 - Lazy <the_lazy_one_09@hotmail.com>
   *
   *  Allows  clients  to  use a jetpack, the command jetpack toggles its
   status.
   * To use the jetpack users simply hold down the jump key provided they
   have enough armor left.
   *
   * New CVars: mp_armorcost, mp_jetpack, mp_smoothboost
   * New Client Commands: jetpack
   *
   *  Notes:  This  is  a  rewrite of my origional jetpack plugin, but it
   still needs the Xtrafun module!!!
   *
   * UPDATE: Updated to work with the CS Smart and Stupid Missiles plugin
   thanks to Ludwig van!
   */
   #include <amxmod>
   #include <xtrafun>
   new jetpack_status[ 33 ]
   new gmsgTextMsg
   new smokesprite
   public plugin_init( )
   {
       register_plugin( "Jetpack", "2.0", "Lazy" )

       register_cvar( "mp_jetpack", "1", FCVAR_SERVER )
       register_cvar( "mp_armorcost", "2", FCVAR_UNLOGGED )
       register_cvar( "mp_smoothboost", "1", FCVAR_UNLOGGED )

       register_clcmd( "jetpack", "CMD_Jetpack", 0, "" )

       gmsgTextMsg = get_user_msgid( "TextMsg" )

       return PLUGIN_CONTINUE
   }
   public plugin_precache( )
   {
       precache_sound( "debris/beamstart15.wav" )
       precache_sound( "weapons/357_cock1.wav" )
       smokesprite = precache_model( "sprites/ballsmoke.spr" )
       return PLUGIN_CONTINUE
   }
   public client_disconnect( id )
   {
       if ( jetpack_status[ id ] == 1 )
       {
           remove_task( id + 500 )
       }

       return PLUGIN_CONTINUE
   }
   public client_connect( id )
   {
       jetpack_status[ id ] = 0

       return PLUGIN_CONTINUE
   }
   public UTIL_TextMsg( id, message[], msg_type )
   {
       message_begin( MSG_ONE, gmsgTextMsg, { 0, 0, 0 }, id )
       write_byte( msg_type )
       write_string( message )
       message_end( )
   }
   public smoke_effect( id )
   {
       new origin[ 3 ]
       get_user_origin( id, origin, 0 )
       origin[2] = origin[2] - 10
       message_begin( MSG_BROADCAST, SVC_TEMPENTITY )
       write_byte( 17 )
       write_coord( origin[0] )
       write_coord( origin[1] )
       write_coord( origin[2] )
       write_short( smokesprite )
       write_byte( 10 )
       write_byte( 150 )
       message_end( )
   }

   public Jetpack_task( player[] )
   {
       new Velocity[ 3 ]
       new Armorcost = get_cvar_num( "mp_armorcost" )
       new id = get_user_index( player )
       new Player_armor = get_user_armor( id )
       new Alive = is_user_alive( id )
       if ( Alive != 1 )
       {
           jetpack_status[ id ] = 0
           remove_task( id + 500 )

           return PLUGIN_HANDLED
       }
       if ( Player_armor < Armorcost )
       {
           remove_task( id + 500 )
           emit_sound(  id,  CHAN_WEAPON,  "debris/beamstart15.wav", 1.0,
   ATTN_NORM, 0, PITCH_NORM )

           jetpack_status[ id ] = 0
           UTIL_TextMsg( id, "Out of armor", print_center )

           return PLUGIN_HANDLED
       }
       if ( get_user_button( id ) & IN_JUMP )
       {
           get_user_velocity( id, Velocity )
           Velocity[2] = Velocity[2] + 250

           set_user_velocity( id, Velocity )
           smoke_effect( id )

           set_user_armor( id, Player_armor - Armorcost )
           set_user_info( id, "JETPACK_RUN", "1" )
       }
       else
       {
           set_user_info( id, "JETPACK_RUN", "0" )
       }

       return PLUGIN_CONTINUE
   }
   public CMD_Jetpack( id )
   {
       new Player[32]
       new Status = get_cvar_num( "mp_jetpack" )
       new Armorcost = get_cvar_num( "mp_armorcost" )
       new Smooth = get_cvar_num( "mp_smoothboost" )
       new Player_armor = get_user_armor( id )
       new Alive = is_user_alive( id )
       get_user_name( id, Player, 32 )

       if ( Status == 1 && jetpack_status[ id ] == 1 )
       {
           jetpack_status[ id ] = 0

           remove_task( id + 500 )
           UTIL_TextMsg( id, "Jetpack off", print_center )

           emit_sound(  id,  CHAN_WEAPON,  "weapons/357_cock1.wav",  1.0,
   ATTN_NORM, 0, PITCH_NORM )

           return PLUGIN_HANDLED
       }
       if ( Status == 1 && jetpack_status[ id ] == 0 )
       {
           if ( Alive != 1 )
           {
               UTIL_TextMsg(  id,  "You  must  be  alive  to  use  this",
   print_center )

               return PLUGIN_HANDLED
           }

           if ( Player_armor < Armorcost )
           {
               UTIL_TextMsg( id, "Not enough armor", print_center )

               return PLUGIN_HANDLED
           }

           UTIL_TextMsg( id, "Jetpack on", print_center )
           emit_sound(  id,  CHAN_WEAPON,  "weapons/357_cock1.wav",  1.0,
   ATTN_NORM, 0, PITCH_NORM )

           jetpack_status[ id ] = 1
           if ( Smooth == 1)
               set_task(  0.20, "Jetpack_task", id + 500, Player, 32, "b"
   )
           else
               set_task(  0.15, "Jetpack_task", id + 500, Player, 32, "b"
   )
       }

       return PLUGIN_HANDLED
   }
