Advertisement
Rejack

Jailbreak - Last Request (Shot4Shot)

Sep 26th, 2020 (edited)
1,776
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Pawn 4.63 KB | None | 0 0
  1. // Includes
  2.  
  3. #include < amxmodx >
  4. #include < cstrike >
  5. #include < fakemeta_util >
  6. #include < hamsandwich >
  7. #include < lastrequest >
  8.  
  9. // Defines
  10.  
  11. #define LR_MODE LR_SHOT_FOR_SHOT        // To decide to which category this plugin match
  12.  
  13. #define TASKID_DELAY    11111   // Don't touch
  14.  
  15. // Enums
  16.  
  17. enum _:BATTLE_IDS
  18. {
  19.     DEAGLE,
  20.     AWP,
  21.     SCOUT,
  22.     USP,
  23.     GLOCK18
  24. };
  25.  
  26. enum _:BATTLE_DATA
  27. {
  28.     BATTLE_NAME[ 32 ],
  29.     BATTLE_WEAPON_CLASS[ 32 ],
  30.     BATTLE_WEAPON_ID,
  31.    
  32.     BATTLE_GUN_EVENT[ 32 ]
  33. };
  34.  
  35. // Strings
  36.  
  37. new const szBattles[ BATTLE_IDS ][ BATTLE_DATA ] =
  38. {
  39.     { "Deagle", "weapon_deagle",    CSW_DEAGLE, "events/deagle.sc" },
  40.     { "AWP",    "weapon_awp",       CSW_AWP,    "events/awp.sc" },
  41.     { "Scout""weapon_scout",     CSW_SCOUT,  "events/scout.sc" },
  42.     { "USP",    "weapon_usp",       CSW_USP,    "events/usp.sc" },
  43.     { "Glock""weapon_glock18",   CSW_GLOCK18,    "events/glock18.sc" }
  44. };
  45.  
  46. // Others
  47.  
  48. new g_iBattleIDs[ BATTLE_IDS ];
  49.  
  50. new g_mGameID   = -1;
  51.  
  52. new g_iVictim
  53. new g_iPlayer;
  54.  
  55. new g_iPrecahceForward;
  56. new g_iEvent_IDs;
  57.  
  58. public plugin_init()
  59. {
  60.     register_plugin( "LR: Basic SHOT v. SHOT", "1.0", "Rejack" );
  61.    
  62.     static i, szBuffer[ 32 ];
  63.    
  64.     for ( i = 0; i < BATTLE_IDS; i++ )  // Register lrs
  65.     {
  66.         formatex( szBuffer, charsmax( szBuffer ), szBattles[ i ][ BATTLE_NAME ] );
  67.        
  68.         g_iBattleIDs[ i ]   = register_shot_lr( szBuffer, true, false );
  69.     }
  70.    
  71.     unregister_forward( FM_PrecacheEvent, g_iPrecahceForward, 1 );
  72.    
  73.     register_forward( FM_PlaybackEvent, "ForwardPlaybackEvent" );
  74. }
  75.  
  76. public plugin_precache( )
  77. {
  78.     g_iPrecahceForward  = register_forward( FM_PrecacheEvent, "ForwardPrecacheEvent", 1 );
  79. }
  80.  
  81. public ForwardPrecacheEvent( type, const name[] )
  82. {
  83.     static i;
  84.    
  85.     for ( i = 0; i < BATTLE_IDS; i++ )
  86.     {
  87.         if ( equal( szBattles[ i ][ BATTLE_GUN_EVENT ], name ) )
  88.         {
  89.             g_iEvent_IDs    |= ( 1 << get_orig_retval( ) );
  90.            
  91.             return 2;
  92.         }
  93.     }
  94.    
  95.     return 1;
  96. }
  97.  
  98. public ForwardPlaybackEvent( iFlags, const client, iEventID )
  99. {
  100.     if ( g_mGameID == -1 )
  101.         return 1;
  102.    
  103.     if ( !is_user_connected( client ) )
  104.         return 1;
  105.    
  106.     if ( !( g_iEvent_IDs & ( 1 << iEventID ) ) )
  107.         return 1;
  108.    
  109.     if ( g_iVictim == client || g_iPlayer == client )   // Is it the player
  110.     {
  111.         cs_set_weapon_ammo( fm_find_ent_by_owner( -1, szBattles[ g_mGameID ][ BATTLE_WEAPON_CLASS ], ( g_iVictim == client ) ? g_iPlayer : g_iVictim ), 1 );
  112.        
  113.         static szName[ 2 ][ 32 ];
  114.        
  115.         get_user_name( ( g_iVictim == client ) ? g_iVictim : g_iPlayer, szName[ 0 ], charsmax( szName[ ] ) );
  116.        
  117.         get_user_name( ( g_iVictim == client ) ? g_iPlayer : g_iVictim, szName[ 1 ], charsmax( szName[] ) );
  118.        
  119.         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 ] );
  120.     }
  121.        
  122.        
  123.     return 2;
  124. }
  125.  
  126. public FwdLrStarted( const client, const victim, const g_iCategory, const iGameID, const g_iDelay )
  127. {
  128.     if ( g_iCategory != LR_MODE )   // Not this category
  129.         return 1;
  130.    
  131.     static i;
  132.    
  133.     for ( i = 0; i < BATTLE_IDS; i++ )      // Look to see if the game Id mathces this plugin
  134.     {
  135.         if ( g_iBattleIDs[ i ] == iGameID )
  136.         {
  137.             g_mGameID   = i;
  138.         }
  139.     }
  140.    
  141.     if ( g_mGameID == -1 )  // If didn't match move on
  142.         return 1;
  143.    
  144.     g_iVictim   = victim;
  145.     g_iPlayer   = client;
  146.    
  147.     set_task( float( g_iDelay ), "taskStartBattle", TASKID_DELAY );
  148.    
  149.     return 1;
  150. }
  151.  
  152. public FwdLrEnded( )
  153. {
  154.     g_mGameID   = -1;
  155.    
  156.     g_iVictim   = 0;
  157.     g_iPlayer   = 0;
  158.    
  159.     if ( task_exists( TASKID_DELAY ) )
  160.         remove_task( TASKID_DELAY );
  161.    
  162.     return 1;
  163. }
  164.  
  165. /* Tasks */
  166.  
  167. public taskStartBattle( )
  168. {
  169.     fm_give_item( g_iPlayer, szBattles[ g_mGameID ][ BATTLE_WEAPON_CLASS ] );
  170.    
  171.     fm_give_item( g_iVictim, szBattles[ g_mGameID ][ BATTLE_WEAPON_CLASS ] );
  172.    
  173.     cs_set_user_bpammo( g_iPlayer, szBattles[ g_mGameID ][ BATTLE_WEAPON_ID ], 0 );
  174.    
  175.     cs_set_user_bpammo( g_iVictim, szBattles[ g_mGameID ][ BATTLE_WEAPON_ID ], 0 );
  176.    
  177.     cs_set_weapon_ammo( fm_find_ent_by_owner( -1, szBattles[ g_mGameID ][ BATTLE_WEAPON_CLASS ], g_iPlayer ), 1 );
  178.    
  179.     cs_set_weapon_ammo( fm_find_ent_by_owner( -1, szBattles[ g_mGameID ][ BATTLE_WEAPON_CLASS ], g_iVictim ), 0 );
  180.    
  181.     return 1;
  182. }
  183.  
  184. /* Stocks */
  185.  
  186. stock ColorPrint( const index, const string[], any:... )
  187. {
  188.     new szMsg[ 512 ], Players[ 32 ], PNum = 1;
  189.    
  190.     static iLen; iLen = formatex( szMsg, charsmax( szMsg ), "^4[%s]^1 ", szPrefix );
  191.    
  192.     vformat( szMsg[ iLen ], charsmax( szMsg ) - iLen, string, 3 );
  193.    
  194.     if ( index )
  195.         Players[ 0 ] = index;
  196.    
  197.     else
  198.         get_players( Players, PNum, "ch" );
  199.    
  200.     for ( new i; i < PNum; i++ )
  201.     {
  202.         if( is_user_connected( Players[ i ] ) )
  203.         {
  204.             message_begin( MSG_ONE_UNRELIABLE, get_user_msgid( "SayText" ), _, Players[ i ] );
  205.            
  206.             write_byte( Players[ i ] );
  207.            
  208.             write_string( szMsg );
  209.            
  210.             message_end( );
  211.         }
  212.     }
  213.    
  214.     return 1;
  215. }
  216.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement