OvidiuS

Knife Vip

Jun 18th, 2014
190
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Pawn 10.39 KB | None | 0 0
  1. /*
  2.     Formatright © 2014
  3.    
  4.     Knife Vip
  5.     Author: OvidiuS
  6.     Original idea: GaMeR_FoReVeR (http://steamcommunity.com/id/GaMeR_FoReVeR/)
  7.     Realease date: 11:20 PM, Wednesday, June 18, 2014 (CEST)
  8.  
  9.     *English*
  10.     This plugin is free software;
  11.     You can modify it under the terms of the
  12.     GNU General Public License as published by the Free Software Foundation.
  13.    
  14.     *Serbian*
  15.     Ovaj plugin je besplatni program;
  16.     Možete ga menjati poštujući prava autora, samo ga ne smete prodavati.
  17.     Svako kršenje GNU licence može da rezultitra tužbom.
  18. */
  19.  
  20. #include < amxmodx >
  21. #include < amxmisc >
  22. #include < fakemeta >
  23. #include < engine >
  24. #include < hamsandwich >
  25. #include < cstrike >
  26. #include < fun >
  27.  
  28. #define flag_set(%1,%2)             ( %1 |= ( 1 << ( %2 & 31 ) ) )
  29. #define flag_rem(%1,%2)             ( %1 &= ~( 1 << ( %2 & 31 ) ) )
  30. #define flag_get(%1,%2)             ( %1 & ( 1 << ( %2 & 31 ) ) )
  31.  
  32. #define MAX_JUMPS                   2
  33. #define XTRA_OFS_PLAYER             5
  34. #define m_afButtonPressed           246
  35.  
  36. #define Ham_CS_Player_ResetMaxSpeed Ham_Item_PreFrame
  37.  
  38. enum
  39. {
  40.     SCOREATTRIB_ARG_PLAYERID = 1,
  41.     SCOREATTRIB_ARG_FLAGS
  42. };
  43.  
  44. enum ( <<= 1 )
  45. {
  46.     SCOREATTRIB_FLAG_NONE = 0,
  47.     SCOREATTRIB_FLAG_DEAD = 1,
  48.     SCOREATTRIB_FLAG_BOMB,
  49.     SCOREATTRIB_FLAG_VIP
  50. };
  51.  
  52. enum CVARS
  53. {
  54.     GRAVITY,
  55.     SPEED,
  56.     MONEY,
  57.     FLAGS_JUMP,
  58.     FLAGS_MONEY,
  59.     FLAGS_GRAVITY,
  60.     FLAGS_SPEED,
  61.     FLAGS_PARACHUTE
  62. };
  63.  
  64. new const global_pCvars[ CVARS ][ ] =
  65. {
  66.     "vip_gravity",
  67.     "vip_speed",
  68.     "vip_money",
  69.     "vip_jump_flags",
  70.     "vip_money_flags",
  71.     "vip_gravity_flags",
  72.     "vip_speed_flags",
  73.     "vip_parachute_flags"
  74. };
  75.  
  76. new const global_pValues[ CVARS ][ ] =
  77. {
  78.     "0.4",
  79.     "500.0",
  80.     "2000",
  81.     "b",
  82.     "t",
  83.     "t",
  84.     "t",
  85.     "t"
  86. };
  87.  
  88. new global_sModels[ ][ ] =
  89. {
  90.     "assasin",
  91.     "doktor"
  92. };
  93.  
  94. new global_msgScreenFade,
  95.     global_bIsVip,
  96.     global_bIsVip_Jump,
  97.     global_bIsVip_Money,
  98.     global_bIsVip_Gravity,
  99.     global_bIsVip_Speed,
  100.     global_bIsVip_Parachute;
  101.  
  102. new global_iPlayerJumps[ 33 ],
  103.     global_iParachuteEntity[ 33 ],
  104.     global_sPlayerModel[ 33 ][ 64 ];
  105.  
  106. new global_cPointer[ CVARS ];
  107.  
  108. public plugin_init( )
  109. {
  110.     register_plugin( "Knife Vip", "0.1", "OvidiuS" );
  111.    
  112.     for ( new CVARS:i = GRAVITY ; i < CVARS ; i++ )
  113.         global_cPointer[ i ] = register_cvar( global_pCvars[ i ], global_pValues[ i ] );
  114.  
  115.     RegisterHam( Ham_Spawn, "player", "ham_Spawn_player_post", .Post = true );
  116.     RegisterHam( Ham_Player_Jump, "player", "ham_Player_Jump_pre" );
  117.     RegisterHam( Ham_CS_Player_ResetMaxSpeed, "player", "ham_ResetMaxSpeed_player_post", .Post = true );
  118.  
  119.     register_forward( FM_SetClientKeyValue, "forward_SetKeyValue" );
  120.     register_event( "DeathMsg", "event_DeathMsg", "a" );
  121.    
  122.     register_message( get_user_msgid( "ClCorpse" ), "message_ClCorpse" );
  123.     register_message( get_user_msgid( "ScoreAttrib" ), "message_ScoreAttrib" );
  124.  
  125.     global_msgScreenFade = get_user_msgid( "ScreenFade" );
  126. }
  127.  
  128. public plugin_precache( )
  129. {
  130.     precache_model( "models/player/doktor/doktor.mdl" );
  131.     precache_model( "models/player/assasin/assasin.mdl" );
  132.     precache_model( "models/parachute.mdl" );
  133. }
  134.  
  135. public client_putinserver( id )
  136. {
  137.     global_sPlayerModel[ id ][ 0 ] = EOS;
  138.  
  139.     new sFlags_Jump[ 2 ], sFlags_Money[ 2 ], sFlags_Gravity[ 2 ], sFlags_Speed[ 2 ], sFlags_Parachute[ 2 ];
  140.  
  141.     get_pcvar_string( global_cPointer[ FLAGS_JUMP ], sFlags_Jump, charsmax( sFlags_Jump ) );
  142.     get_pcvar_string( global_cPointer[ FLAGS_MONEY ], sFlags_Money, charsmax( sFlags_Money ) );
  143.     get_pcvar_string( global_cPointer[ FLAGS_GRAVITY ], sFlags_Gravity, charsmax( sFlags_Gravity ) );
  144.     get_pcvar_string( global_cPointer[ FLAGS_SPEED ], sFlags_Speed, charsmax( sFlags_Speed ) );
  145.     get_pcvar_string( global_cPointer[ FLAGS_PARACHUTE ], sFlags_Parachute, charsmax( sFlags_Parachute ) );
  146.  
  147.     new iFlags              = get_user_flags( id );
  148.     new iFlags_Jump         = read_flags( sFlags_Jump );
  149.     new iFlags_Money        = read_flags( sFlags_Money );
  150.     new iFlags_Gravity      = read_flags( sFlags_Gravity );
  151.     new iFlags_Speed        = read_flags( sFlags_Speed );
  152.     new iFlags_Parachute    = read_flags( sFlags_Parachute );
  153.  
  154.     if( iFlags & iFlags_Jump || iFlags & iFlags_Money || iFlags & iFlags_Gravity || iFlags & iFlags_Speed || iFlags & iFlags_Parachute )
  155.     {
  156.         flag_set( global_bIsVip, id )
  157.  
  158.         if( iFlags & iFlags_Jump )
  159.             flag_set( global_bIsVip_Jump, id );
  160.  
  161.         if( iFlags & iFlags_Money )
  162.             flag_set( global_bIsVip_Money, id );
  163.  
  164.         if( iFlags & iFlags_Gravity )
  165.             flag_set( global_bIsVip_Gravity, id );
  166.  
  167.         if( iFlags & iFlags_Speed )
  168.             flag_set( global_bIsVip_Speed, id );
  169.  
  170.         if( iFlags & iFlags_Parachute )
  171.             flag_set( global_bIsVip_Parachute, id );
  172.     }
  173. }
  174.  
  175. public client_disconnect( id )
  176. {
  177.     flag_rem( global_bIsVip, id );
  178.     flag_rem( global_bIsVip_Jump, id );
  179.     flag_rem( global_bIsVip_Gravity, id );
  180.     flag_rem( global_bIsVip_Speed, id );
  181.     flag_rem( global_bIsVip_Parachute, id );
  182. }
  183.  
  184. public client_PreThink( id )
  185. {
  186.     if( flag_get( global_bIsVip_Parachute, id ) )
  187.     {
  188.         if( !is_user_alive( id ) )
  189.             return;
  190.    
  191.         new button      = get_user_button( id );
  192.         new flags       = get_entity_flags( id );
  193.        
  194.         if( button & IN_USE )
  195.         {
  196.             if( !( flags & FL_ONGROUND ) )
  197.             {
  198.                 new Float:fVelocity[ 3 ];
  199.                 entity_get_vector( id, EV_VEC_velocity, fVelocity );
  200.                
  201.                 if( fVelocity[ 2 ] < 0.0 )
  202.                 {
  203.                     if( global_iParachuteEntity[ id ] <= 0 )
  204.                     {
  205.                         global_iParachuteEntity[ id ] = create_entity( "info_target" );
  206.  
  207.                         if( global_iParachuteEntity[ id ] > 0 )
  208.                         {
  209.                             entity_set_model( global_iParachuteEntity[ id ], "models/parachute.mdl" );
  210.                             entity_set_int( global_iParachuteEntity[ id ], EV_INT_movetype, MOVETYPE_FOLLOW );
  211.                             entity_set_edict( global_iParachuteEntity[ id ], EV_ENT_aiment, id );
  212.                         }
  213.                     }
  214.                    
  215.                     if( global_iParachuteEntity[ id ] > 0 )
  216.                     {
  217.                         fVelocity[ 2 ] = ( fVelocity[ 2 ] + 40.0 < -100.0 ) ? fVelocity[ 2 ] + 40.0 : -100.0;
  218.                         entity_set_vector( id, EV_VEC_velocity, fVelocity );
  219.                        
  220.                         if( entity_get_float( global_iParachuteEntity[ id ], EV_FL_frame) < 0.0 || entity_get_float( global_iParachuteEntity[ id ] , EV_FL_frame ) > 254.0 )
  221.                         {
  222.                             if( entity_get_int( global_iParachuteEntity[ id ], EV_INT_sequence) != 1 )
  223.                                 entity_set_int( global_iParachuteEntity[ id ], EV_INT_sequence, 1 );
  224.  
  225.                             entity_set_float( global_iParachuteEntity[ id ], EV_FL_frame, 0.0 );
  226.                         }
  227.                         else
  228.                             entity_set_float( global_iParachuteEntity[ id ], EV_FL_frame, entity_get_float( global_iParachuteEntity[ id ], EV_FL_frame ) + 1.0 );
  229.                     }
  230.                 }
  231.                 else if( global_iParachuteEntity[ id ] > 0 )
  232.                 {
  233.                     remove_entity( global_iParachuteEntity[ id ] )
  234.                     global_iParachuteEntity[ id ] = 0
  235.                 }
  236.             }
  237.             else if( global_iParachuteEntity[ id ] > 0 )
  238.             {
  239.                     remove_entity( global_iParachuteEntity[ id ] )
  240.                     global_iParachuteEntity[ id ] = 0
  241.             }
  242.         }
  243.         else if( global_iParachuteEntity[ id ] > 0 )
  244.         {
  245.             remove_entity( global_iParachuteEntity[ id ] )
  246.             global_iParachuteEntity[ id ] = 0
  247.         }
  248.     }
  249. }
  250.  
  251. public ham_Spawn_player_post( id )
  252. {
  253.     if( is_user_alive( id ) && flag_get( global_bIsVip, id ) )
  254.     {
  255.         new CsTeams:iTeam = cs_get_user_team( id );
  256.  
  257.         if( iTeam == CS_TEAM_CT || iTeam == CS_TEAM_T )
  258.         {
  259.             copy( global_sPlayerModel[ id ], charsmax( global_sPlayerModel[ ] ), global_sModels[ _:iTeam - 1 ] );
  260.             set_user_info( id, "model", global_sPlayerModel[ id ] );
  261.         }
  262.  
  263.         if( global_iParachuteEntity[ id ] > 0 )
  264.         {
  265.             remove_entity( global_iParachuteEntity[ id ] )
  266.             entity_set_float( id, EV_FL_gravity, 1.0 );
  267.  
  268.             global_iParachuteEntity[ id ] = 0;
  269.         }
  270.  
  271.         if( flag_get( global_bIsVip_Gravity, id ) )
  272.             entity_set_float( id, EV_FL_gravity, 1.0 - get_pcvar_float( global_cPointer[ GRAVITY ] ) );
  273.  
  274.         if( flag_get( global_bIsVip_Money, id ) )
  275.             cs_set_user_money( id, cs_get_user_money( id ) + get_pcvar_num( global_cPointer[ MONEY ] ) );
  276.     }
  277. }
  278.  
  279. public ham_ResetMaxSpeed_player_post( id )
  280. {
  281.     if( flag_get( global_bIsVip_Speed, id ) )
  282.     {
  283.         static Float:flSpeed;
  284.         flSpeed = get_pcvar_float( global_cPointer[ SPEED ] );
  285.        
  286.         engfunc( EngFunc_SetClientMaxspeed, id, flSpeed );
  287.         set_pev( id, pev_maxspeed, flSpeed );
  288.  
  289.         //client_cmd( id, "cl_forwardspeed %0.1f;cl_sidespeed %0.1f;cl_backspeed %0.1f", flSpeed, flSpeed, flSpeed );
  290.     }
  291. }
  292.  
  293. public ham_Player_Jump_pre( id )
  294. {
  295.     if( !is_user_alive( id ) )
  296.         return HAM_IGNORED;
  297.  
  298.     new fFlags = pev( id, pev_flags );
  299.    
  300.     if( fFlags & FL_WATERJUMP || pev( id, pev_waterlevel ) >= 2 || !( get_pdata_int( id, m_afButtonPressed, XTRA_OFS_PLAYER ) & IN_JUMP ) )
  301.     {
  302.         return HAM_IGNORED;
  303.     }
  304.  
  305.     if( fFlags & FL_ONGROUND )
  306.     {
  307.         global_iPlayerJumps[ id ] = 0;
  308.         return HAM_IGNORED;
  309.     }
  310.  
  311.     if( flag_get( global_bIsVip_Jump, id ) && ++global_iPlayerJumps[ id ] < MAX_JUMPS )
  312.     {
  313.         new Float:fVelocity[ 3 ];
  314.         pev( id, pev_velocity, fVelocity );
  315.         fVelocity[ 2 ] = random_float( 265.0, 285.0 );
  316.         set_pev( id, pev_velocity, fVelocity );
  317.  
  318.         return HAM_HANDLED;
  319.     }
  320.     return HAM_IGNORED;
  321. }
  322.  
  323. public event_DeathMsg( )
  324. {
  325.     new iAttacker = read_data( 1 );
  326.     new iVictim = read_data( 2 );
  327.  
  328.     if( global_iParachuteEntity[ iVictim ] > 0 )
  329.     {
  330.         if( is_valid_ent( global_iParachuteEntity[ iVictim  ] ) )
  331.             remove_entity( global_iParachuteEntity[ iVictim  ] );
  332.  
  333.         global_iParachuteEntity[ iVictim ] = 0;
  334.     }
  335.  
  336.     if( iVictim != iAttacker )
  337.     {
  338.         if( flag_get( global_bIsVip, iVictim ) )
  339.             UTIL_ScreenFade( iVictim, 1<<14, 1<<14, 1<<16, 0, 200, 250, 230 );
  340.     }
  341. }
  342.  
  343. public forward_SetKeyValue( id, const _szInfoBuffer[ ], const _szKey[ ], const _szValue[ ] )
  344. {
  345.     if( global_sPlayerModel[ id ][ 0 ] && equal( _szKey, "model" ) && !equal( _szValue, global_sPlayerModel[ id ] ) )
  346.     {
  347.         set_user_info( id, "model", global_sPlayerModel[ id ] );
  348.         return FMRES_SUPERCEDE;
  349.     }
  350.     return FMRES_IGNORED;
  351. }
  352.  
  353. public message_ClCorpse( )
  354. {
  355.     new id = get_msg_arg_int( 12 );
  356.  
  357.     if( global_sPlayerModel[ id ][ 0 ] )
  358.         set_msg_arg_string( 1, global_sPlayerModel[ id ] );
  359. }
  360.  
  361. public message_ScoreAttrib( msgId, iDestination, iReceiver )
  362. {
  363.     new id = get_msg_arg_int( SCOREATTRIB_ARG_PLAYERID );
  364.    
  365.     if( flag_get( global_bIsVip, id ) )
  366.         set_msg_arg_int( SCOREATTRIB_ARG_FLAGS, ARG_BYTE, SCOREATTRIB_FLAG_VIP );
  367. }
  368.  
  369. stock UTIL_ScreenFade( id, iDuration, iHoldtime, iFadetype, red, green, blue, alpha )
  370. {
  371.     message_begin( MSG_ONE, global_msgScreenFade, { 0, 0, 0 }, id );
  372.     write_short( iDuration );   // Duration of fadeout
  373.     write_short( iHoldtime );   // Hold time of color
  374.     write_short( iFadetype );   // Fade type
  375.     write_byte ( red );         // Red
  376.     write_byte ( green );       // Green
  377.     write_byte ( blue );        // Blue
  378.     write_byte ( alpha );       // Alpha
  379.     message_end( );
  380. }
Add Comment
Please, Sign In to add comment