Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- // Includes
- #include < amxmodx >
- #include < cstrike >
- #include < fakemeta_util >
- #include < hamsandwich >
- #include < lastrequest >
- // Defines
- #define LR_MODE LR_SHOT_FOR_SHOT // To decide to which category this plugin match
- #define TASKID_DELAY 11111 // Don't touch
- // Enums
- enum _:BATTLE_IDS
- {
- DEAGLE,
- AWP,
- SCOUT,
- USP,
- GLOCK18
- };
- enum _:BATTLE_DATA
- {
- BATTLE_NAME[ 32 ],
- BATTLE_WEAPON_CLASS[ 32 ],
- BATTLE_WEAPON_ID,
- BATTLE_GUN_EVENT[ 32 ]
- };
- // Strings
- new const szBattles[ BATTLE_IDS ][ BATTLE_DATA ] =
- {
- { "Deagle", "weapon_deagle", CSW_DEAGLE, "events/deagle.sc" },
- { "AWP", "weapon_awp", CSW_AWP, "events/awp.sc" },
- { "Scout", "weapon_scout", CSW_SCOUT, "events/scout.sc" },
- { "USP", "weapon_usp", CSW_USP, "events/usp.sc" },
- { "Glock", "weapon_glock18", CSW_GLOCK18, "events/glock18.sc" }
- };
- // Others
- new g_iBattleIDs[ BATTLE_IDS ];
- new g_mGameID = -1;
- new g_iVictim
- new g_iPlayer;
- new g_iPrecahceForward;
- new g_iEvent_IDs;
- public plugin_init()
- {
- register_plugin( "LR: Basic SHOT v. SHOT", "1.0", "Rejack" );
- static i, szBuffer[ 32 ];
- for ( i = 0; i < BATTLE_IDS; i++ ) // Register lrs
- {
- formatex( szBuffer, charsmax( szBuffer ), szBattles[ i ][ BATTLE_NAME ] );
- g_iBattleIDs[ i ] = register_shot_lr( szBuffer, true, false );
- }
- unregister_forward( FM_PrecacheEvent, g_iPrecahceForward, 1 );
- register_forward( FM_PlaybackEvent, "ForwardPlaybackEvent" );
- }
- public plugin_precache( )
- {
- g_iPrecahceForward = register_forward( FM_PrecacheEvent, "ForwardPrecacheEvent", 1 );
- }
- public ForwardPrecacheEvent( type, const name[] )
- {
- static i;
- for ( i = 0; i < BATTLE_IDS; i++ )
- {
- if ( equal( szBattles[ i ][ BATTLE_GUN_EVENT ], name ) )
- {
- g_iEvent_IDs |= ( 1 << get_orig_retval( ) );
- return 2;
- }
- }
- return 1;
- }
- public ForwardPlaybackEvent( iFlags, const client, iEventID )
- {
- if ( g_mGameID == -1 )
- return 1;
- if ( !is_user_connected( client ) )
- return 1;
- if ( !( g_iEvent_IDs & ( 1 << iEventID ) ) )
- return 1;
- if ( g_iVictim == client || g_iPlayer == client ) // Is it the player
- {
- cs_set_weapon_ammo( fm_find_ent_by_owner( -1, szBattles[ g_mGameID ][ BATTLE_WEAPON_CLASS ], ( g_iVictim == client ) ? g_iPlayer : g_iVictim ), 1 );
- static szName[ 2 ][ 32 ];
- get_user_name( ( g_iVictim == client ) ? g_iVictim : g_iPlayer, szName[ 0 ], charsmax( szName[ ] ) );
- get_user_name( ( g_iVictim == client ) ? g_iPlayer : g_iVictim, szName[ 1 ], charsmax( szName[] ) );
- ColorPrint( 0, "^3%s^1 just took a^4 SHOT^1!, Its^3 %s^1's turn to^4 SHOT^1!", szName[ 0 ], szName[ 1 ] );
- }
- return 2;
- }
- public FwdLrStarted( const client, const victim, const g_iCategory, const iGameID, const g_iDelay )
- {
- if ( g_iCategory != LR_MODE ) // Not this category
- return 1;
- static i;
- for ( i = 0; i < BATTLE_IDS; i++ ) // Look to see if the game Id mathces this plugin
- {
- if ( g_iBattleIDs[ i ] == iGameID )
- {
- g_mGameID = i;
- }
- }
- if ( g_mGameID == -1 ) // If didn't match move on
- return 1;
- g_iVictim = victim;
- g_iPlayer = client;
- set_task( float( g_iDelay ), "taskStartBattle", TASKID_DELAY );
- return 1;
- }
- public FwdLrEnded( )
- {
- g_mGameID = -1;
- g_iVictim = 0;
- g_iPlayer = 0;
- if ( task_exists( TASKID_DELAY ) )
- remove_task( TASKID_DELAY );
- return 1;
- }
- /* Tasks */
- public taskStartBattle( )
- {
- fm_give_item( g_iPlayer, szBattles[ g_mGameID ][ BATTLE_WEAPON_CLASS ] );
- fm_give_item( g_iVictim, szBattles[ g_mGameID ][ BATTLE_WEAPON_CLASS ] );
- cs_set_user_bpammo( g_iPlayer, szBattles[ g_mGameID ][ BATTLE_WEAPON_ID ], 0 );
- cs_set_user_bpammo( g_iVictim, szBattles[ g_mGameID ][ BATTLE_WEAPON_ID ], 0 );
- cs_set_weapon_ammo( fm_find_ent_by_owner( -1, szBattles[ g_mGameID ][ BATTLE_WEAPON_CLASS ], g_iPlayer ), 1 );
- cs_set_weapon_ammo( fm_find_ent_by_owner( -1, szBattles[ g_mGameID ][ BATTLE_WEAPON_CLASS ], g_iVictim ), 0 );
- return 1;
- }
- /* Stocks */
- stock ColorPrint( const index, const string[], any:... )
- {
- new szMsg[ 512 ], Players[ 32 ], PNum = 1;
- static iLen; iLen = formatex( szMsg, charsmax( szMsg ), "^4[%s]^1 ", szPrefix );
- vformat( szMsg[ iLen ], charsmax( szMsg ) - iLen, string, 3 );
- if ( index )
- Players[ 0 ] = index;
- else
- get_players( Players, PNum, "ch" );
- for ( new i; i < PNum; i++ )
- {
- if( is_user_connected( Players[ i ] ) )
- {
- message_begin( MSG_ONE_UNRELIABLE, get_user_msgid( "SayText" ), _, Players[ i ] );
- write_byte( Players[ i ] );
- write_string( szMsg );
- message_end( );
- }
- }
- return 1;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement