Rejack

Amxx Piss (Short Version)

Apr 1st, 2013 (edited)
150
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Pawn 6.21 KB | None | 0 0
  1. #include < amxmodx >
  2. #include < engine >
  3.  
  4. new piCount[ 33 ], puCount[ 33 ], bool:PissFlag[ 33 ], Aim[ 33 ], Float:aOrigin[ 33 ][ 3 ];
  5.  
  6. new Models[ 5 ][ ] =
  7. {
  8.     "models/piss/piss_puddle1.mdl",
  9.     "models/piss/piss_puddle2.mdl",
  10.     "models/piss/piss_puddle3.mdl",
  11.     "models/piss/piss_puddle4.mdl",
  12.     "models/piss/piss_puddle5.mdl"
  13. };
  14.  
  15. new Puddles[ 5 ][ ] =
  16. {
  17.     "piss_puddle1",
  18.     "piss_puddle2",
  19.     "piss_puddle3",
  20.     "piss_puddle4",
  21.     "piss_puddle5"
  22. };
  23.  
  24. public plugin_init()
  25. {
  26.     register_plugin( "AMXX Piss (Short Version)", "1.0", "Rejack" );
  27.    
  28.     register_clcmd( "piss", "CmdPissOn" );
  29.    
  30.     register_event( "DeathMsg", "evDeathMsg", "a" );
  31.    
  32.     register_event( "ResetHUD", "evResetHud", "be" );
  33.  
  34.     return PLUGIN_CONTINUE
  35. }
  36.  
  37.  
  38. public plugin_precache()
  39. {
  40.     precache_sound( "piss/pissing.wav");
  41.    
  42.     precache_model( Models[ 0 ] );
  43.     precache_model( Models[ 1 ] );
  44.     precache_model( Models[ 2 ] );
  45.     precache_model( Models[ 3 ] );
  46.     precache_model( Models[ 4 ] );
  47.  
  48.     return PLUGIN_CONTINUE
  49. }
  50.  
  51. public client_connect( client )
  52. {
  53.     PissFlag[ client ] = false;
  54.    
  55.     piCount[ client ] = 1;
  56. }
  57.  
  58. public client_disconnect( client )
  59.     evResetHud( client );
  60.  
  61. public CmdPissOn( client )
  62. {
  63.     if ( !is_user_alive( client ) )
  64.         return ColorPrint( client, "You need to be^4 Alive^1." );
  65.        
  66.     if ( PissFlag[ client ] || piCount[ client ] > 1 )
  67.         return ColorPrint( client, "You can only^3 Piss^1 once per round!" );
  68.        
  69.     static szName[ 32 ];get_user_name( client, szName, charsmax( szName ) );
  70.    
  71.     ColorPrint( 0, "^4%s^1 just took a^3 Piss^1!", szName );
  72.    
  73.     piCount[ client ] += 1;
  74.    
  75.     puCount[ client ] = 1;
  76.    
  77.     new Clients[ 1 ];
  78.    
  79.     Clients[ 0 ] = client;
  80.    
  81.     PissFlag[ client ] = true;
  82.    
  83.     Aim[ client ] = true;
  84.    
  85.     emit_sound( client, CHAN_VOICE, "piss/pissing.wav", 1.0, ATTN_NORM, 0, PITCH_NORM );
  86.    
  87.     set_task( 0.2, "CmdPiss", 1481 + client, Clients, 1, "a", 48 );
  88.    
  89.     set_task( 2.2, "CmdCreatePiss", 3424 + client, Clients, 1, "a", 4 );
  90.    
  91.     return 1;
  92. }
  93.  
  94. public Sqrt( Num )
  95. {
  96.     new Div = Num;
  97.    
  98.     new Result = 1;
  99.    
  100.     while ( Div > Result )
  101.     {
  102.         Div = ( Div + Result ) / 2;
  103.        
  104.         Result = Num / Div;
  105.     }
  106.    
  107.     return Div;
  108. }
  109.  
  110. public CmdPiss( const Clients[] )
  111. {
  112.     new client = Clients[ 0 ], Vec[ 3 ], AimVec[ 3 ], Velocity[ 3 ], Length;
  113.    
  114.     get_user_origin( client, Vec );
  115.    
  116.     get_user_origin( client, AimVec, 3 );
  117.    
  118.     new Distance = get_distance( Vec, AimVec );
  119.    
  120.     new Speed = floatround( Distance * 1.9 );
  121.  
  122.     Velocity[ 0 ] = AimVec[ 0 ] - Vec[ 0 ];
  123.     Velocity[ 1 ] = AimVec[ 1 ] - Vec[ 1 ];
  124.     Velocity[ 2 ] = AimVec[ 2 ] - Vec[ 2 ];
  125.  
  126.     Length = Sqrt( Velocity[ 0 ] * Velocity[ 0 ] + Velocity[ 1 ] * Velocity[ 1 ] + Velocity[ 2 ] * Velocity[ 2 ] );
  127.  
  128.     Velocity[ 0 ] = Velocity[ 0 ] * Speed / Length;
  129.     Velocity[ 1 ] = Velocity[ 1 ] * Speed / Length;
  130.     Velocity[ 2 ] = Velocity[ 2 ] * Speed / Length;
  131.  
  132.     message_begin(MSG_BROADCAST,SVC_TEMPENTITY)
  133.     write_byte( 101 );
  134.     write_coord( Vec[ 0 ] );
  135.     write_coord( Vec[ 1 ] );
  136.     write_coord( Vec[ 2 ] );
  137.     write_coord( Velocity[ 0 ] );
  138.     write_coord( Velocity[ 1 ] );
  139.     write_coord( Velocity[ 2 ] );
  140.     write_byte( 102 );  // color
  141.     write_byte( 160 );  // speed
  142.     message_end();
  143. }
  144.  
  145. public CmdCreatePiss( const Clients[] )
  146. {
  147.     new client = Clients[ 0 ];
  148.    
  149.     if ( !Aim[ client ] )
  150.     {
  151.         new iOrigin[ 3 ];
  152.        
  153.         get_user_origin( client, iOrigin, 3 );
  154.        
  155.         aOrigin[ client ][ 0 ] = float( iOrigin[ 0 ] );
  156.        
  157.         aOrigin[ client ][ 1 ] = float( iOrigin[ 1 ] );
  158.        
  159.         aOrigin[ client ][ 2 ] = float( iOrigin[ 2 ] );
  160.     }
  161.    
  162.     new ent = create_entity( "info_target" );
  163.    
  164.     if ( ent == 0 )
  165.         return 1;
  166.  
  167.     new Float:MinBox[ 3 ];
  168.    
  169.     new Float:MaxBox[ 3 ];
  170.  
  171.     MinBox[ 0 ] = -1.0;
  172.    
  173.     MinBox[ 1 ] = -1.0;
  174.    
  175.     MinBox[ 2 ] = -1.0;
  176.    
  177.     MaxBox[ 0 ] = 1.0;
  178.    
  179.     MaxBox[ 1 ] = 1.0;
  180.    
  181.     MaxBox[ 2 ] = 1.0;
  182.  
  183.     entity_set_vector( ent, EV_VEC_mins, MinBox );
  184.    
  185.     entity_set_vector( ent, EV_VEC_maxs, MaxBox );
  186.    
  187.     entity_set_string( ent, EV_SZ_classname, Puddles[ puCount[ client ] - 1 ] );
  188.    
  189.     entity_set_model( ent, Models[ puCount[ client ] - 1 ] );
  190.    
  191.     entity_set_origin( ent, aOrigin[ client ] );
  192.    
  193.     entity_set_int( ent, EV_INT_solid, 3 );
  194.    
  195.     entity_set_int( ent, EV_INT_movetype, 6 );
  196.    
  197.     entity_set_edict( ent, EV_ENT_owner, client );
  198.    
  199.     puCount[ client ]++;
  200.    
  201.     Aim[ client ] = true;
  202.    
  203.     return 0;
  204. }
  205.  
  206. public evDeathMsg( )
  207. {
  208.     new Victim = read_data(2)
  209.    
  210.     if ( PissFlag[ Victim ] )
  211.         CmdReset( Victim );
  212.  
  213.     return 0;
  214. }
  215.  
  216. public CmdReset( client )
  217. {
  218.     if ( task_exists( 1481 + client ) )
  219.         remove_task( 1481 + client );
  220.    
  221.     if ( task_exists( 3424 + client ) )
  222.         remove_task( 3424 + client );
  223.    
  224.     emit_sound( client, CHAN_VOICE, "piss/pissing.wav", 0.0, ATTN_NORM, 0, PITCH_NORM );
  225.    
  226.     PissFlag[ client ] = false;
  227.    
  228.     return 0;
  229. }
  230.  
  231. public evResetHud( client )
  232. {
  233.     if ( task_exists( 1481 + client ) )
  234.         remove_task( 1481 + client );
  235.        
  236.     if ( task_exists( 3424 + client ) )
  237.         remove_task( 3424 + client );
  238.    
  239.     emit_sound( client, CHAN_VOICE, "piss/pissing.wav", 0.0, ATTN_NORM, 0, PITCH_NORM )
  240.    
  241.     PissFlag[ client ] = false;
  242.  
  243.     new ent;
  244.    
  245.     for ( new i = 1; i < piCount[ client ]; i++ )
  246.     {        
  247.         ent = find_ent_by_class( -1, "piss_puddle1" );
  248.        
  249.         if ( ent != -1 )
  250.             remove_entity( ent );
  251.            
  252.         ent = find_ent_by_class( -1, "piss_puddle2" );
  253.        
  254.         if ( ent != -1)
  255.             remove_entity( ent );
  256.            
  257.         ent = find_ent_by_class( -1, "piss_puddle3" );
  258.        
  259.         if ( ent != -1)
  260.             remove_entity( ent );
  261.            
  262.         ent = find_ent_by_class( -1, "piss_puddle4" );
  263.        
  264.         if ( ent != -1)
  265.             remove_entity( ent );
  266.            
  267.         ent = find_ent_by_class( -1, "piss_puddle5" );
  268.        
  269.         if ( ent != -1)
  270.             remove_entity( ent );
  271.     }
  272.    
  273.     piCount[ client ] = 1;
  274.  
  275.     return 0;
  276. }
  277.  
  278. stock ColorPrint( const client, const szString[], any:... )
  279. {
  280.     new szMsg[ 191 ], Players[ 32 ], PNum = 1;
  281.    
  282.     static Len; Len = formatex( szMsg, charsmax( szMsg ), "^4[AMXX]^1 " );
  283.    
  284.     vformat( szMsg[ Len ], charsmax ( szMsg ) - Len, szString, 3 );
  285.    
  286.     if ( client )   Players[ 0 ] = client;
  287.    
  288.     else    get_players( Players, PNum, "ch" );
  289.    
  290.     for ( new i; i < PNum; i++ )
  291.     {
  292.         if ( is_user_connected( Players[ i ] ) )
  293.         {
  294.             message_begin( MSG_ONE_UNRELIABLE, get_user_msgid( "SayText" ) ,_, Players[ i ] );
  295.            
  296.             write_byte( Players[ i ] );
  297.            
  298.             write_string( szMsg );
  299.            
  300.             message_end( );
  301.         }
  302.     }
  303.    
  304.     return 1;
  305. }
Advertisement
Add Comment
Please, Sign In to add comment