Rejack

Amxx Puke (Short Version)

Apr 7th, 2013 (edited)
109
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Pawn 4.17 KB | None | 0 0
  1. #include < amxmodx >
  2.  
  3. new pCount[ 33 ], Counter[ 33 ], bool:Aim[ 33 ], bool:PukeFlag[ 33 ];
  4.  
  5. new Info[ 4 ][ ] =
  6. {
  7.     "Amxx Puke (Short Version)",
  8.     "1.0",
  9.     "Rejack",
  10.     "AMXX"      // Prefix
  11. };
  12.  
  13. public plugin_init()
  14. {
  15.     register_plugin( Info[ 0 ], Info[ 1 ], Info[ 2 ] );
  16.    
  17.     register_clcmd( "puke", "CmdPuke" );
  18.    
  19.     register_clcmd( "vomit", "CmdPuke" );
  20.    
  21.     register_event( "DeathMsg", "evDeathMsg", "a" );
  22.    
  23.     register_event( "ResetHUD", "evResetHud", "be" );
  24. }
  25.  
  26. public plugin_precache()
  27. {
  28.     precache_sound( "puke/puke.wav" );
  29.    
  30.     precache_sound( "puke/puke2.wav" );
  31. }
  32.  
  33. public CmdPuke( client )
  34. {
  35.     if ( !is_user_alive( client ) )
  36.         return ColorPrint( client, "You need to be^4 Alive^1." );
  37.    
  38.     if ( PukeFlag[ client ] || pCount[ client ] > 1 )
  39.         return ColorPrint( client, "You can^3 Puke^1 only^4 Once^1 per round!" );
  40.    
  41.     ColorPrint( 0, "^4%s^1 is^3 Puking^1!!", szName( client ) );
  42.    
  43.     pCount[ client ]++;
  44.    
  45.     new Clients[ 1 ];
  46.    
  47.     Clients[ 0 ] = client;
  48.    
  49.     PukeFlag[ client ] = true;
  50.    
  51.     Aim[ client ] = false;
  52.    
  53.     Counter[ client ] = 0;
  54.    
  55.     switch ( random_num( 0,1 ) )
  56.     {
  57.         case 0: emit_sound( client, CHAN_VOICE, "puke/puke.wav", 1.0, ATTN_NORM, 0, PITCH_NORM );
  58.        
  59.         case 1: emit_sound( client, CHAN_VOICE, "puke/puke2.wav", 1.0, ATTN_NORM, 0, PITCH_NORM );
  60.     }
  61.    
  62.     set_task( 0.3, "CmdCreatePuke", 2412+client, Clients, 1, "a", 9 );
  63.    
  64.     return 1;
  65. }
  66.  
  67. public Sqrt( Num )
  68. {
  69.     new Div = Num;
  70.    
  71.     new Result = 1;
  72.    
  73.     while ( Div > Result )
  74.     {
  75.         Div = ( Div + Result ) / 2
  76.        
  77.         Result = Num / Div;
  78.     }
  79.    
  80.     return Div;
  81. }
  82.  
  83. public CmdCreatePuke( const Clients[ ] )
  84. {
  85.     new client = Clients[ 0 ], Vec[ 3 ], AimVec[ 3 ], VelocityVec[ 3 ], Length;
  86.    
  87.     get_user_origin( client, Vec, 1 );
  88.    
  89.     get_user_origin( client, AimVec, 3 );
  90.    
  91.     new Distance    = get_distance( Vec, AimVec );
  92.    
  93.     new Speed   = floatround( Distance * 1.9 );
  94.    
  95.     VelocityVec[ 0 ] = AimVec[ 0 ] - Vec[ 0 ];
  96.     VelocityVec[ 1 ] = AimVec[ 1 ] - Vec[ 1 ];
  97.     VelocityVec[ 2 ] = AimVec[ 2 ] - Vec[ 2 ];
  98.    
  99.     Length = Sqrt( VelocityVec[ 0 ] * VelocityVec[ 0 ] + VelocityVec[ 1 ] * VelocityVec[ 1 ] + VelocityVec[ 2 ] * VelocityVec[ 2 ] );
  100.    
  101.     VelocityVec[ 0 ] = VelocityVec[ 0 ] * Speed / Length;
  102.     VelocityVec[ 1 ] = VelocityVec[ 1 ] * Speed / Length;
  103.     VelocityVec[ 2 ] = VelocityVec[ 2 ] * Speed / Length;
  104.    
  105.     message_begin( MSG_BROADCAST, SVC_TEMPENTITY );
  106.     write_byte( 101 );
  107.     write_coord( Vec[ 0 ] );
  108.     write_coord( Vec[ 1 ] );
  109.     write_coord( Vec[ 2 ] - 2 );
  110.     write_coord( VelocityVec[ 0 ] );
  111.     write_coord( VelocityVec[ 1 ] );
  112.     write_coord( VelocityVec[ 2 ] );
  113.     write_byte( 82 );
  114.     write_byte( 160 );
  115.     message_end( )
  116.    
  117.     Counter[ client ]++;
  118.    
  119.     if ( Counter[ client ] == 9 )
  120.         PukeFlag[ client ] = false;
  121. }
  122.  
  123. public evDeathMsg( )
  124. {
  125.     new iVictim = read_data(2)
  126.    
  127.     if ( PukeFlag[ iVictim ] )
  128.         evResetPuke( iVictim );
  129. }
  130.  
  131. public evResetPuke( client )
  132. {
  133.     if ( task_exists( 2412+client ) )
  134.         remove_task( 2412+client );
  135.        
  136.     emit_sound( client, CHAN_VOICE,"puke/puke.wav", 0.0, ATTN_NORM, 0, PITCH_NORM );
  137.    
  138.     PukeFlag[ client ] = false;
  139. }
  140.  
  141. public evResetHud( client )
  142. {
  143.     if ( task_exists( 2412+client ) )
  144.         remove_task( 2412+client );
  145.        
  146.     emit_sound( client, CHAN_VOICE,"puke/puke.wav", 0.0, ATTN_NORM, 0, PITCH_NORM );
  147.    
  148.     PukeFlag[ client ] = false;
  149.    
  150.     pCount[ client ] = 1;
  151. }
  152.  
  153. public client_putinserver( client )
  154. {
  155.     PukeFlag[ client ] = false;
  156.    
  157.     pCount[ client ] = 1;
  158. }
  159.  
  160. public client_disconnect( client )
  161.     evResetHud( client );
  162.  
  163. stock ColorPrint( const client, const string[], any:... )
  164. {
  165.     new msg[ 191 ], players[ 32 ], count = 1;
  166.    
  167.     static len; len = formatex( msg, charsmax( msg ), "^4[%s]^1 ", Info[ 3 ] );
  168.    
  169.     vformat( msg[ len ], charsmax( msg ) - len, string, 3 );
  170.    
  171.     if( client )  players[ 0 ] = client;
  172.    
  173.     else    get_players( players,count,"ch" );
  174.    
  175.     for ( new i = 0; i < count; i++ )
  176.     {
  177.         if( is_user_connected( players[ i ] ) )
  178.         {
  179.             message_begin( MSG_ONE_UNRELIABLE, get_user_msgid( "SayText" ), _, players[ i ] );
  180.            
  181.             write_byte( players[ i ] );
  182.            
  183.             write_string( msg );
  184.            
  185.             message_end( );
  186.         }
  187.     }
  188.     return PLUGIN_HANDLED;
  189. }
  190.  
  191. stock szName( const index )
  192. {
  193.     static Name[ 128 ];
  194.    
  195.     get_user_name( index, Name, charsmax( Name ) );
  196.    
  197.     return Name;
  198. }
Advertisement
Add Comment
Please, Sign In to add comment