Rejack

JailBreak Dodgeball Day v0.1b by Rejack

Mar 16th, 2013 (edited)
173
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Pawn 9.43 KB | None | 0 0
  1. #include < amxmodx >
  2. #include < fakemeta >
  3. #include < fakemeta_util >
  4. #include < engine >
  5. #include < cstrike >
  6. #include < csx >
  7.  
  8. /* Variables */
  9.     new Sprite, Shockwave,
  10.  
  11. /* Arrays */
  12.     g_Models[ 3 ][ ] =
  13.     {
  14.         "models/p_dodgeball.mdl",
  15.         "models/v_dodgeball.mdl",
  16.         "models/w_dodgeball.mdl"
  17.     },
  18.    
  19.     g_Sound[ ] =
  20.     {
  21.         "weapons/g_bounce1.wav"
  22.     },
  23.     g_Sprite[ ][ ] =
  24.     {
  25.         "sprites/lgtning.spr",
  26.         "sprites/white.spr"
  27.     };
  28. /* Booleans */
  29.     new bool:Dodgeball;
  30.  
  31. public plugin_init( )
  32. {
  33.     register_plugin( "Dodgeball Day", "0.1b", "Rejack" );
  34.    
  35.     register_clcmd( "say /db", "CmdStartDay" );
  36.    
  37.     register_event( "CurWeapon", "evCurWeapon", "b" );
  38.    
  39.     register_event( "RoundTime", "evRoundTime", "bc" );
  40.    
  41.     register_message( get_user_msgid( "SendAudio" ), "MsgAudio" );
  42.    
  43.     register_message( get_user_msgid( "TextMsg" ), "MsgText" );
  44.    
  45.     register_touch( "*", "player", "PlayerInteract" );
  46.    
  47.     register_touch( "grenade", "*", "BallInteract" );
  48.    
  49.     register_forward( FM_SetModel, "FwdSetModel", 0 );
  50.    
  51.     register_forward( FM_EmitSound, "FwdEmitSound", 0 );
  52.    
  53.     register_think( "grenade", "FwdThinkGrenade" );
  54. }
  55.  
  56. public plugin_precache( )
  57. {
  58.     for ( new i; i < 3; i++ )
  59.         precache_model( g_Models[ i ] );
  60.        
  61.     Sprite      = precache_model( g_Sprite[ 0 ] );
  62.     Shockwave   = precache_model( g_Sprite[ 1 ] );
  63.    
  64.     precache_sound( g_Sound );
  65. }
  66.  
  67. public CmdStartDay( client )
  68. {
  69.     if ( Dodgeball )    return client_print( client, print_chat, "[AMXX] Dodgeball day has already started." );
  70.    
  71.     if ( !(get_user_flags( client ) & ADMIN_BAN) )  return client_print( client, print_chat, "[AMXX] You don't have access to this." );
  72.    
  73.     if ( !is_user_alive( client ) ) return client_print( client, print_chat, "[AMXX] You need to be Alive." );
  74.    
  75.     static szName[ 32 ];get_user_name( client, szName, charsmax( szName ) );
  76.    
  77.     client_print( 0, print_chat, "[AMXX] %s started Dodgeball Day!", szName );
  78.    
  79.     Dodgeball = true;
  80.    
  81.     for ( new i; i < get_maxplayers( ); i++ )
  82.     {
  83.         if ( !is_user_alive( client ) || !is_user_connected( i ) ) continue;
  84.        
  85.         if ( cs_get_user_team( i ) == CS_TEAM_T )
  86.         {
  87.             fm_strip_user_weapons( i );
  88.            
  89.             fm_set_user_health( i, 100 );
  90.            
  91.             fm_give_item( i, "weapon_hegrenade" );
  92.            
  93.             cs_set_user_bpammo( i, CSW_HEGRENADE, 999 );
  94.         }
  95.         else
  96.         {
  97.             fm_strip_user_weapons( i );
  98.            
  99.             fm_give_item( i, "weapon_knife" );
  100.            
  101.             fm_set_user_godmode( i, 1 );
  102.         }
  103.     }
  104.    
  105.     return 0;
  106. }
  107.  
  108. public grenade_throw( client, GrenadeIndex, WeaponID )
  109. {
  110.     if ( Dodgeball )
  111.     {
  112.         if ( WeaponID == CSW_HEGRENADE )
  113.         {
  114.             entity_set_edict( GrenadeIndex, EV_ENT_euser1, client );
  115.             entity_set_int( GrenadeIndex, EV_INT_iuser1, 0 );
  116.             entity_set_size( GrenadeIndex, Float:{-6.0,-6.0,-6.0}, Float:{6.0,6.0,6.0} );
  117.             entity_set_float( GrenadeIndex, EV_FL_friction, 0.6 );
  118.            
  119.             message_begin( MSG_BROADCAST, SVC_TEMPENTITY );
  120.             write_byte( TE_BEAMFOLLOW );
  121.             write_short( GrenadeIndex );
  122.             write_short( Sprite );
  123.             write_byte( 20 );
  124.             write_byte( 5 );
  125.             write_byte( 0 );
  126.             write_byte( 255 );
  127.             write_byte( 255 );
  128.             write_byte( 255 );
  129.             message_end( );
  130.            
  131.             set_rendering( GrenadeIndex, kRenderFxGlowShell, 0, 255, 255 );
  132.            
  133.             set_task( 0.1, "CmdStopRolling" ,GrenadeIndex );
  134.         }
  135.     }
  136. }
  137.  
  138. public CmdStopRolling( ent )
  139. {
  140.     if ( Dodgeball )
  141.     {
  142.         if( is_valid_ent( ent ) )
  143.         {
  144.             if( get_entity_flags( ent ) & FL_ONGROUND )
  145.             {
  146.                 entity_set_vector( ent, EV_VEC_velocity, Float:{0.0,0.0,0.0} );
  147.                 entity_set_float( ent, EV_FL_gravity, 1.0 );
  148.                 remove_entity( ent );
  149.             }
  150.            
  151.             else set_task( 0.1, "CmdStopRolling", ent );
  152.         }
  153.     }
  154. }
  155.  
  156. public PlayerInteract( ent, client )
  157. {
  158.     if ( Dodgeball )
  159.     {
  160.         if ( !is_valid_ent( ent ) ) return 0;
  161.        
  162.         new szClassname[ 32 ], szModel[ 32 ];
  163.        
  164.         entity_get_string( ent, EV_SZ_classname, szClassname, charsmax( szClassname ) );
  165.        
  166.         entity_get_string( ent, EV_SZ_model, szModel, charsmax( szModel ) );
  167.        
  168.         if ( equali( szClassname, "armoury_entity" ) )
  169.         {
  170.    
  171.             if ( equali( szModel, g_Models[ 2 ] ) )
  172.             {
  173.                 if ( user_has_dodgeball( client ) <= 0 )
  174.                 {
  175.                     fm_give_item( client, "weapon_hegrenade" );
  176.                    
  177.                     remove_entity( ent );
  178.                 }
  179.             }
  180.    
  181.             return 1;
  182.         }
  183.        
  184.         if( equali ( szClassname, "grenade") )
  185.             CmdHitByBall( client, ent );
  186.     }
  187.    
  188.     return PLUGIN_CONTINUE;
  189. }
  190.  
  191. public BallInteract( ball, ent )
  192. {
  193.     if ( Dodgeball )
  194.     {
  195.         if ( ent == 0 )
  196.         {
  197.             entity_set_int( ball, EV_INT_iuser1, 1 );
  198.            
  199.             set_rendering( ball );
  200.         }
  201.        
  202.         else
  203.         {
  204.             new szClassname[ 32] ;
  205.            
  206.             entity_get_string( ent, EV_SZ_classname, szClassname, charsmax( szClassname ) );
  207.            
  208.             if ( equali ( szClassname, "func_", 5 ) )
  209.             {
  210.                 entity_set_int( ball, EV_INT_iuser1, 1 );
  211.                
  212.                 set_rendering( ball );
  213.             }
  214.         }
  215.     }
  216. }
  217.  
  218. public CmdHitByBall( client, ball )
  219. {
  220.     if ( Dodgeball )
  221.     {
  222.         if ( cs_get_user_team( client ) != CS_TEAM_T )  return 1;
  223.        
  224.         if( entity_get_int( ball, EV_INT_iuser1 ) == 1 )
  225.         {
  226.             if( user_has_dodgeball( client ) <= 0 )
  227.                 remove_entity( ball );
  228.                
  229.             return 1;
  230.         }
  231.        
  232.         new Owner = entity_get_edict( ball, EV_ENT_euser1 );
  233.        
  234.         if( Owner == client )
  235.         {
  236.             remove_entity( ball );
  237.            
  238.             return 1;
  239.         }
  240.        
  241.         new Float:iOrigin[ 3 ], Float:vec[ 3 ], Float:bOrigin[ 3 ], Float:Maxs[ 3 ];
  242.        
  243.         entity_get_vector( ball, EV_VEC_origin, iOrigin );
  244.        
  245.         get_velocity( client, iOrigin, 5120.0, vec );
  246.        
  247.         vec[2] = 512.0;
  248.        
  249.         entity_set_vector( client, EV_VEC_velocity, vec );
  250.        
  251.         fm_set_user_godmode( client, 1 );
  252.        
  253.         set_task( 0.1, "CmdKill" ,client );
  254.        
  255.         remove_entity( ball );
  256.        
  257.         entity_get_vector( client, EV_VEC_maxs, Maxs );
  258.        
  259.         entity_get_vector( client, EV_VEC_origin, bOrigin);
  260.        
  261.         bOrigin[ 2 ] += Maxs[ 2 ];
  262.        
  263.         entity_set_int( ball, EV_INT_iuser1, 1 );
  264.     }
  265.    
  266.     return PLUGIN_CONTINUE;
  267. }
  268.  
  269. public CmdKill( client )
  270. {
  271.     if ( Dodgeball )
  272.     {
  273.         user_silentkill( client );
  274.        
  275.         new iOrigin[ 3 ]
  276.        
  277.         get_user_origin( client , iOrigin, 1 );
  278.        
  279.         death_beam( iOrigin )
  280.     }
  281. }
  282.  
  283. /* Events */
  284.  
  285. public evRoundTime( )
  286. {
  287.     new ent;
  288.    
  289.     while( ( ent = find_ent_by_class( ent, "grenade" ) ) != 0 ) remove_entity( ent );
  290.    
  291.     Dodgeball = false;
  292. }
  293.  
  294. public evCurWeapon( client )
  295. {
  296.     if ( Dodgeball )
  297.     {
  298.         new Clip, Ammo, Weapon = get_user_weapon( client, Clip, Ammo );
  299.        
  300.         if( Weapon == CSW_HEGRENADE )
  301.         {
  302.             entity_set_string( client, EV_SZ_viewmodel, g_Models[ 1 ] );
  303.            
  304.             entity_set_string( client, EV_SZ_weaponmodel, g_Models[ 0 ] );
  305.         }
  306.     }
  307. }
  308.  
  309. /* Forwards */
  310.  
  311. public FwdSetModel( ent, szModel[ ] )
  312. {
  313.     if ( Dodgeball )
  314.     {
  315.         if ( equali( szModel, "models/w_hegrenade.mdl" ) )
  316.         {
  317.             entity_set_model( ent, "models/w_dodgeball.mdl" );
  318.            
  319.             return FMRES_SUPERCEDE;
  320.         }
  321.     }
  322.    
  323.     return FMRES_IGNORED;
  324. }
  325.  
  326. public FwdEmitSound( ent, channel, sample[], Float:volume, Float:atten, flags, pitch)
  327. {
  328.     if ( Dodgeball )
  329.     {
  330.         if( containi( sample, "he_bounce" ) != -1 )
  331.         {
  332.             if ( entity_get_float( ent, EV_FL_fuser1 ) + 0.3 < get_gametime( ) )
  333.             {
  334.                 entity_set_float( ent, EV_FL_fuser1, get_gametime( ) );
  335.                
  336.                 emit_sound( ent, CHAN_ITEM, g_Sound, VOL_NORM, ATTN_NORM, 0, PITCH_NORM );
  337.             }
  338.             return FMRES_SUPERCEDE;
  339.         }
  340.     }
  341.    
  342.     return FMRES_IGNORED;
  343. }
  344.  
  345. public FwdThinkGrenade( ent )
  346. {
  347.     if ( Dodgeball )
  348.     {
  349.         new szModel[ 32 ];
  350.         entity_get_string( ent, EV_SZ_model, szModel, charsmax( szModel ) );
  351.    
  352.         if ( !equali( szModel, g_Models[ 2 ] ) )
  353.             return 0;
  354.            
  355.         return 1;
  356.     }
  357.    
  358.     return PLUGIN_CONTINUE;
  359. }
  360.  
  361. /* Messages */
  362.  
  363. public MsgAudio()
  364. {
  365.     if ( Dodgeball )
  366.     {
  367.         new szString[ 32 ];
  368.        
  369.         get_msg_arg_string( 2, szString, charsmax( szString ) );
  370.        
  371.         if ( equal( szString, "%!MRAD_FIREINHOLE" ) )
  372.             return 1;
  373.     }
  374.    
  375.     return PLUGIN_CONTINUE;
  376. }
  377.  
  378. public MsgText()
  379. {
  380.     if ( Dodgeball )
  381.     {
  382.         new szString[ 32 ];
  383.        
  384.         get_msg_arg_string( 2, szString, charsmax( szString ) );
  385.        
  386.         if ( equali( szString, "#Weapon_Cannot_Be_Dropped" ) )
  387.             return 1;
  388.        
  389.         if ( str_to_num( szString ) > 0 )
  390.         {
  391.             get_msg_arg_string( 3, szString, charsmax( szString ) );
  392.             if ( equali( szString, "#Game_radio" ) )
  393.             {
  394.                 get_msg_arg_string( 5, szString, charsmax( szString ) );
  395.                 if ( equali( szString, "#Fire_in_the_hole" ) )
  396.                     return 1;
  397.             }
  398.         }
  399.     }
  400.    
  401.     return PLUGIN_CONTINUE;
  402. }
  403.  
  404. /* Stocks */
  405.  
  406. stock user_has_dodgeball( client )
  407. {
  408.     new Clip, Ammo;
  409.    
  410.     get_user_ammo( client, CSW_HEGRENADE, Clip, Ammo );
  411.    
  412.     return Ammo;
  413. }
  414.  
  415. stock get_velocity( ent, Float:fOrigin[ 3 ], Float:fSpeed, Float:fVelocity[ 3 ] )
  416. {
  417.     new Float:fEntOrigin[3];
  418.     entity_get_vector(ent,EV_VEC_origin,fEntOrigin);
  419.    
  420.     new Float:fDistance[3];
  421.     fDistance[0] = fEntOrigin[0] - fOrigin[0];
  422.     fDistance[1] = fEntOrigin[1] - fOrigin[1];
  423.     fDistance[2] = fEntOrigin[2] - fOrigin[2];
  424.    
  425.     new Float:fTime = ( vector_distance( fEntOrigin,fOrigin ) / fSpeed );
  426.    
  427.     fVelocity[0] = fDistance[0] / fTime;
  428.     fVelocity[1] = fDistance[1] / fTime;
  429.     fVelocity[2] = fDistance[2] / fTime;
  430.    
  431.     return (fVelocity[0] && fVelocity[1] && fVelocity[2]);
  432. }
  433.  
  434. stock death_beam( iOrigin[ 3 ] )
  435. {
  436.     message_begin(MSG_PVS, SVC_TEMPENTITY, iOrigin)
  437.     write_byte(TE_BEAMCYLINDER);
  438.     write_coord(iOrigin[0]);
  439.     write_coord(iOrigin[1]);
  440.     write_coord(iOrigin[2]);
  441.     write_coord(iOrigin[0]);
  442.     write_coord(iOrigin[1]);
  443.     write_coord(iOrigin[2] + 200);
  444.    
  445.     write_short( Shockwave );
  446.    
  447.     write_byte( 0 );
  448.     write_byte( 0 );
  449.     write_byte( 5 );
  450.     write_byte( 75 );
  451.     write_byte( 0 );
  452.     write_byte ( 255 ); // Red
  453.     write_byte ( 255 ); // Green
  454.     write_byte ( 255 ); // Blue
  455.     write_byte( 255 );
  456.     write_byte( 0 );
  457.     message_end( );
  458. }
Advertisement
Add Comment
Please, Sign In to add comment