Rejack

Jailbreak - Last Request (API) - Rules Example

Sep 26th, 2020
908
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. #define USE_RULES
  2.  
  3. // Includes
  4.  
  5. #include < amxmodx >
  6. #include < cstrike >
  7. #include < fakemeta_util >
  8. #include < lastrequest >
  9.  
  10. // Defines
  11.  
  12. #define LR_MODE LR_CUSTOME_BATTLES      // To decide to which category this plugin match
  13.  
  14. #define TASKID_DELAY    11111   // Don't touch
  15.  
  16. // Enums
  17.  
  18. enum _:BATTLE_IDS
  19. {
  20.     M4A1,
  21.     AK47,
  22.     AWP,
  23.     SCOUT,
  24.     USP,
  25.     M3,
  26.     XM1014,
  27.     M249,
  28.     GALIL,
  29.     AUG,
  30.     FAMAS
  31. };
  32.  
  33. enum _:BATTLE_DATA
  34. {
  35.     BATTLE_NAME[ 32 ],
  36.     BATTLE_WEAPON_CLASS[ 32 ],
  37.     BATTLE_WEAPON_ID
  38. };
  39.  
  40. // Strings
  41.  
  42. new const szBattles[ BATTLE_IDS ][ BATTLE_DATA ] =
  43. {
  44.     { "M4A1 Battles",   "weapon_m4a1",  CSW_M4A1 },
  45.     { "AK47 Battles",   "weapon_ak47",  CSW_AK47 },
  46.     { "AWP Battles",        "weapon_awp",   CSW_AWP },
  47.     { "SCOUT Battles""weapon_scout", CSW_SCOUT },
  48.     { "USP Battles",        "weapon_usp",   CSW_USP },
  49.     { "M3 Battles",     "weapon_m3",    CSW_M3 },
  50.     { "XM1014 Battles", "weapon_xm1014",CSW_XM1014 },
  51.     { "M249 Battles",   "weapon_m249",  CSW_M249 },
  52.     { "GALIL Battles""weapon_galil", CSW_GALIL },
  53.     { "AUG Battles",        "weapon_aug",   CSW_AUG },
  54.     { "FAMAS Battles""weapon_famas", CSW_FAMAS }
  55. };
  56.  
  57. // Others
  58.  
  59. new g_iBattleIDs[ BATTLE_IDS ];
  60.  
  61. new g_mGameID   = -1;
  62.  
  63. new g_iVictim
  64. new g_iPlayer;
  65.  
  66. public plugin_init()
  67. {
  68.     register_plugin( "LR: Basic Custome Wars", "1.0", "Rejack" );
  69.    
  70.     static i, szBuffer[ 32 ];
  71.    
  72.     for ( i = 0; i < BATTLE_IDS; i++ )  // Register lrs
  73.     {
  74.         formatex( szBuffer, charsmax( szBuffer ), szBattles[ i ][ BATTLE_NAME ] );
  75.        
  76.         g_iBattleIDs[ i ]   = register_custome_lr( szBuffer, true, true, "cmdOpenRulesMenu" );
  77.        
  78.         if ( g_iBattleIDs[ i ] == -1 )
  79.             log_amx( "[LR:Basic Custome Wars] ERROR: Failed to register custome_lr (i=%i) : %s", i, szBattles[ i ][ BATTLE_NAME ] );
  80.     }
  81. }
  82.  
  83. public cmdOpenRulesMenu( const client )
  84. {
  85.     set_rule( bNoBunnyhop, false );
  86.     set_rule( bHeadshot, false );
  87.    
  88.     return cmdSelectRules( client );
  89. }
  90.    
  91. public cmdSelectRules( const client )
  92. {
  93.     static Menu, szItem[ 128 ];
  94.    
  95.     formatex( szItem, charsmax( szItem ), "\r[%s]\w Last Request Menu^n^nSelect battle rules!", szPrefix );
  96.    
  97.     Menu     = menu_create( szItem, "handlerSelectRules" );
  98.    
  99.     formatex( szItem, charsmax( szItem ), "%s:%s", szRules[ bNoBunnyhop ], get_rule( bNoBunnyhop ) ? "\r ON" : "\y OFF" );
  100.    
  101.     menu_additem( Menu, szItem );
  102.    
  103.     formatex( szItem, charsmax( szItem ), "%s:%s", szRules[ bHeadshot ], get_rule( bHeadshot ) ? "\r ON" : "\y OFF" );
  104.    
  105.     menu_additem( Menu, szItem );
  106.    
  107.     menu_setprop( Menu, MPROP_EXITNAME, "Back" );
  108.    
  109.     menu_display( client, Menu );
  110.    
  111.     return 1;
  112. }
  113.  
  114. public handlerSelectRules( client, Menu, Item )
  115. {
  116.     menu_destroy( Menu );
  117.    
  118.     switch ( Item )
  119.     {
  120.         case 0:
  121.             set_rule( bNoBunnyhop, !get_rule( bNoBunnyhop ) );
  122.        
  123.         case 1:
  124.             set_rule( bHeadshot, !get_rule( bHeadshot ) );
  125.        
  126.         default:
  127.             return userExitRules( client );
  128.     }
  129.    
  130.     return cmdSelectRules( client );
  131. }
  132.  
  133. public FwdLrStarted( const client, const victim, const g_iCategory, const iGameID, const g_iDelay )
  134. {
  135.     if ( g_iCategory != LR_MODE )   // Not this category
  136.         return 1;
  137.    
  138.     static i;
  139.    
  140.     for ( i = 0; i < BATTLE_IDS; i++ )      // Look to see if the game Id mathces this plugin
  141.     {
  142.         if ( g_iBattleIDs[ i ] == iGameID )
  143.         {
  144.             g_mGameID   = i;
  145.         }
  146.     }
  147.    
  148.     if ( g_mGameID == -1 )  // If didn't match move on
  149.         return 1;
  150.    
  151.     g_iVictim   = victim;
  152.     g_iPlayer   = client;
  153.    
  154.     set_task( float( g_iDelay ), "taskStartBattle", TASKID_DELAY );
  155.    
  156.     return 1;
  157. }
  158.  
  159. public FwdLrEnded( )
  160. {
  161.     g_mGameID   = -1;
  162.    
  163.     g_iVictim   = 0;
  164.     g_iPlayer   = 0;
  165.    
  166.     if ( task_exists( TASKID_DELAY ) )
  167.         remove_task( TASKID_DELAY );
  168.    
  169.     return 1;
  170. }
  171.  
  172. public taskStartBattle( )
  173. {
  174.     fm_give_item( g_iVictim, szBattles[ g_mGameID ][ BATTLE_WEAPON_CLASS ] );
  175.    
  176.     fm_give_item( g_iVictim, szBattles[ g_mGameID ][ BATTLE_WEAPON_CLASS ] );
  177.    
  178.     cs_set_user_bpammo( g_iPlayer, szBattles[ g_mGameID ][ BATTLE_WEAPON_ID ], 9999 );
  179.    
  180.     cs_set_user_bpammo( g_iPlayer, szBattles[ g_mGameID ][ BATTLE_WEAPON_ID ], 9999 );
  181.    
  182.     return 1;
  183. }
  184.  
RAW Paste Data