Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include < amxmodx >
- #include < fakemeta >
- #include < fakemeta_util >
- #include < engine >
- #include < cstrike >
- #include < csx >
- native bool: is_user_lr( const index );
- native bool: is_lr_active();
- native stop_lr( Num = 0 );
- native bool: is_lr_dodgeball();
- /* Variables */
- new Sprite,
- /* Arrays */
- g_Models[ 3 ][ ] =
- {
- "models/Top/JB/LR/p_dodgeball.mdl",
- "models/Top/JB/LR/v_dodgeball.mdl",
- "models/Top/JB/LR/w_dodgeball.mdl"
- };
- new g_Sprite[ ][ ] = {"sprites/lgtning.spr" };
- new const g_Sound[ ] = "weapons/g_bound1.wav";
- new g_mBalls[ 33 ];
- public plugin_init( )
- {
- register_plugin( "Dodgeball Day", "0.1b", "Built by Rejack || Edit by @.TheBomB`" );
- register_event( "CurWeapon", "evCurWeapon", "b" );
- //register_event( "RoundTime", "evRoundTime", "bc" );
- register_message( get_user_msgid( "SendAudio" ), "MsgAudio" );
- register_message( get_user_msgid( "TextMsg" ), "MsgText" );
- register_touch( "*", "player", "PlayerInteract" );
- register_touch( "grenade", "*", "BallInteract" );
- register_forward( FM_SetModel, "FwdSetModel", 0 );
- register_forward( FM_EmitSound, "FwdEmitSound", 0 );
- register_think( "grenade", "FwdThinkGrenade" );
- }
- public plugin_natives()
- {
- register_library( "dbnative" );
- register_native( "start_dodgeball", "native_start_dodgeball" );
- register_native( "GetUserBalls", "nativeGetUserBalls" );
- }
- public plugin_precache( )
- {
- for ( new i; i < 3; i++ )
- precache_model( g_Models[ i ] );
- Sprite = precache_model( g_Sprite[ 0 ] );
- precache_sound( g_Sound );
- }
- public native_start_dodgeball( plugin, params )
- {
- static index, client;
- index = get_param( 1 );
- client = get_param( 2 );
- fm_strip_user_weapons( index );
- fm_set_user_health( index, 100 );
- fm_give_item( index, "weapon_hegrenade" );
- cs_set_user_bpammo( index, CSW_HEGRENADE, 999 );
- fm_strip_user_weapons( client );
- fm_set_user_health( client, 100 );
- fm_give_item( client, "weapon_hegrenade" );
- cs_set_user_bpammo( client, CSW_HEGRENADE, 999 );
- g_mBalls[ index ] = 0;
- g_mBalls[ client ] = 0;
- }
- public nativeGetUserBalls( plugin, params )
- return g_mBalls[ get_param( 1 ) ];
- public grenade_throw( client, GrenadeIndex, WeaponID )
- {
- if ( CheckLr( client ) )
- {
- if ( WeaponID == CSW_HEGRENADE )
- {
- entity_set_edict( GrenadeIndex, EV_ENT_euser1, client );
- entity_set_int( GrenadeIndex, EV_INT_iuser1, 0 );
- entity_set_size( GrenadeIndex, Float:{-6.0,-6.0,-6.0}, Float:{6.0,6.0,6.0} );
- entity_set_float( GrenadeIndex, EV_FL_friction, 0.6 );
- message_begin( MSG_BROADCAST, SVC_TEMPENTITY );
- write_byte( TE_BEAMFOLLOW );
- write_short( GrenadeIndex );
- write_short( Sprite );
- write_byte( 20 );
- write_byte( 5 );
- write_byte( 0 );
- write_byte( 255 );
- write_byte( 255 );
- write_byte( 255 );
- message_end( );
- set_rendering( GrenadeIndex, kRenderFxGlowShell, 0, 255, 255 );
- g_mBalls[ client ]++;
- set_task( 0.1, "CmdStopRolling" ,GrenadeIndex );
- }
- }
- }
- public CmdStopRolling( ent )
- {
- if ( CheckLr( 0 ) )
- {
- if( is_valid_ent( ent ) )
- {
- if( get_entity_flags( ent ) & FL_ONGROUND )
- {
- entity_set_vector( ent, EV_VEC_velocity, Float:{0.0,0.0,0.0} );
- entity_set_float( ent, EV_FL_gravity, 1.0 );
- remove_entity( ent );
- }
- else set_task( 0.1, "CmdStopRolling", ent );
- }
- }
- }
- public PlayerInteract( ent, client )
- {
- if ( CheckLr( client ) )
- {
- if ( !is_valid_ent( ent ) ) return 0;
- new szClassname[ 32 ], szModel[ 32 ];
- entity_get_string( ent, EV_SZ_classname, szClassname, charsmax( szClassname ) );
- entity_get_string( ent, EV_SZ_model, szModel, charsmax( szModel ) );
- if ( equali( szClassname, "armoury_entity" ) )
- {
- if ( equali( szModel, g_Models[ 2 ] ) )
- {
- if ( user_has_dodgeball( client ) <= 0 )
- {
- fm_give_item( client, "weapon_hegrenade" );
- remove_entity( ent );
- }
- }
- return 1;
- }
- if( equali ( szClassname, "grenade") )
- CmdHitByBall( client, ent );
- }
- return PLUGIN_CONTINUE;
- }
- public BallInteract( ball, ent )
- {
- if ( CheckLr( 0 ) )
- {
- if ( ent == 0 )
- {
- entity_set_int( ball, EV_INT_iuser1, 1 );
- set_rendering( ball );
- }
- else
- {
- new szClassname[ 32] ;
- entity_get_string( ent, EV_SZ_classname, szClassname, charsmax( szClassname ) );
- if ( equali ( szClassname, "func_", 5 ) )
- {
- entity_set_int( ball, EV_INT_iuser1, 1 );
- set_rendering( ball );
- }
- }
- }
- }
- public CmdHitByBall( client, ball )
- {
- if ( CheckLr( client ) )
- {
- if( entity_get_int( ball, EV_INT_iuser1 ) == 1 )
- {
- if( user_has_dodgeball( client ) <= 0 )
- remove_entity( ball );
- return 1;
- }
- new Owner = entity_get_edict( ball, EV_ENT_euser1 );
- if( Owner == client )
- {
- remove_entity( ball );
- return 1;
- }
- if ( !CheckLr( Owner ) )
- return 1;
- new Float:iOrigin[ 3 ], Float:vec[ 3 ], Float:bOrigin[ 3 ], Float:Maxs[ 3 ];
- entity_get_vector( ball, EV_VEC_origin, iOrigin );
- get_velocity( client, iOrigin, 5120.0, vec );
- vec[2] = 512.0;
- entity_set_vector( client, EV_VEC_velocity, vec );
- fm_set_user_godmode( client, 1 );
- set_task( 0.1, "CmdKill" ,client );
- remove_entity( ball );
- entity_get_vector( client, EV_VEC_maxs, Maxs );
- entity_get_vector( client, EV_VEC_origin, bOrigin);
- bOrigin[ 2 ] += Maxs[ 2 ];
- entity_set_int( ball, EV_INT_iuser1, 1 );
- }
- return 0;
- }
- public CmdKill( client )
- {
- if ( CheckLr( client ) )
- {
- user_silentkill( client );
- new iOrigin[ 3 ]
- get_user_origin( client , iOrigin, 1 );
- stop_lr( 1 );
- }
- }
- /* Events */
- public evRoundTime( )
- {
- new ent;
- while( ( ent = find_ent_by_class( ent, "grenade" ) ) != 0 ) remove_entity( ent );
- stop_lr( 1 );
- }
- public evCurWeapon( client )
- {
- if ( CheckLr( client ) )
- {
- new Clip, Ammo, Weapon = get_user_weapon( client, Clip, Ammo );
- if( Weapon == CSW_HEGRENADE )
- {
- entity_set_string( client, EV_SZ_viewmodel, g_Models[ 1 ] );
- entity_set_string( client, EV_SZ_weaponmodel, g_Models[ 0 ] );
- }
- }
- }
- /* Forwards */
- public FwdSetModel( ent, szModel[ ] )
- {
- if ( CheckLr( 0 ) )
- {
- if ( equali( szModel, "models/w_hegrenade.mdl" ) )
- {
- entity_set_model( ent, g_Models[ 2 ] );
- return FMRES_SUPERCEDE;
- }
- }
- return FMRES_IGNORED;
- }
- public FwdEmitSound( ent, channel, sample[], Float:volume, Float:atten, flags, pitch)
- {
- if ( CheckLr( 0 ) )
- {
- if( containi( sample, "he_bounce" ) != -1 )
- {
- if ( entity_get_float( ent, EV_FL_fuser1 ) + 0.3 < get_gametime( ) )
- {
- entity_set_float( ent, EV_FL_fuser1, get_gametime( ) );
- emit_sound( ent, CHAN_ITEM, g_Sound, VOL_NORM, ATTN_NORM, 0, PITCH_NORM );
- }
- return FMRES_SUPERCEDE;
- }
- }
- return FMRES_IGNORED;
- }
- public FwdThinkGrenade( ent )
- {
- if ( !CheckLr( 0 ) )
- return 0;
- new szModel[ 64 ];
- entity_get_string( ent, EV_SZ_model, szModel, charsmax( szModel ) );
- if ( !equali( szModel, g_Models[ 2 ] ) )
- return 0;
- return 1;
- }
- /* Messages */
- public MsgAudio()
- {
- if ( CheckLr( 0 ) )
- {
- new szString[ 32 ];
- get_msg_arg_string( 2, szString, charsmax( szString ) );
- if ( equal( szString, "%!MRAD_FIREINHOLE" ) )
- return 1;
- }
- return PLUGIN_CONTINUE;
- }
- public MsgText()
- {
- if ( CheckLr( 0 ) )
- {
- new szString[ 32 ];
- get_msg_arg_string( 2, szString, charsmax( szString ) );
- if ( equali( szString, "#Weapon_Cannot_Be_Dropped" ) )
- return 1;
- if ( str_to_num( szString ) > 0 )
- {
- get_msg_arg_string( 3, szString, charsmax( szString ) );
- if ( equali( szString, "#Game_radio" ) )
- {
- get_msg_arg_string( 5, szString, charsmax( szString ) );
- if ( equali( szString, "#Fire_in_the_hole" ) )
- return 1;
- }
- }
- }
- return PLUGIN_CONTINUE;
- }
- /* Stocks */
- stock user_has_dodgeball( client )
- {
- new Clip, Ammo;
- get_user_ammo( client, CSW_HEGRENADE, Clip, Ammo );
- return Ammo;
- }
- stock get_velocity( ent, Float:fOrigin[ 3 ], Float:fSpeed, Float:fVelocity[ 3 ] )
- {
- new Float:fEntOrigin[3];
- entity_get_vector(ent,EV_VEC_origin,fEntOrigin);
- new Float:fDistance[3];
- fDistance[0] = fEntOrigin[0] - fOrigin[0];
- fDistance[1] = fEntOrigin[1] - fOrigin[1];
- fDistance[2] = fEntOrigin[2] - fOrigin[2];
- new Float:fTime = ( vector_distance( fEntOrigin,fOrigin ) / fSpeed );
- fVelocity[0] = fDistance[0] / fTime;
- fVelocity[1] = fDistance[1] / fTime;
- fVelocity[2] = fDistance[2] / fTime;
- return (fVelocity[0] && fVelocity[1] && fVelocity[2]);
- }
- stock bool: CheckLr( const index )
- {
- if ( index > 0 && is_user_lr( index ) && is_lr_active() && is_lr_dodgeball() || index == 0 && is_lr_active() && is_lr_dodgeball() )
- return true;
- return false;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement