Rejack

Jailbreak: Games

Jan 8th, 2017 (edited)
122
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Pawn 3.58 KB | None | 0 0
  1. // Includes
  2. #include < amxmodx >
  3. #include < cstrike >
  4. #include < jbGamesAPI >
  5. #include < fakemeta_util >
  6.  
  7. // Defines
  8. #define ADMIN_ACCESS    ADMIN_KICK
  9.  
  10. new g_iGame[ 33 ];
  11. new szItem[ 128 ];
  12.  
  13. public plugin_init()
  14. {
  15.     register_plugin( "Jailbreak: Games", "1.0", "Rejack" );
  16.    
  17.     register_clcmd( "say /games", "cmdPreMainMenu" );
  18. }
  19.  
  20. public fwGamesWinner( const client )
  21. {
  22.     fm_set_user_rendering( client, kRenderFxGlowShell, 255, 255, 255, kRenderNormal, 36 );  // Glow
  23.    
  24.     ColorPrint( 0, "^3%s^1 has won the^4 %s^1 contest.", szName( client ), szEvents[ get_game_type() ] );
  25.    
  26.     set_hudmessage( 255, 0, 0, -1.0, 0.35, 1, 2.5, 8.0, 0.1, 0.1, 3 );
  27.     show_hudmessage( 0, "%s has won the %s contest!", szName( client ), szEvents[ get_game_type() ] );
  28. }
  29.  
  30. public cmdPreMainMenu( const client )
  31. {
  32.     if ( cs_get_user_team( client ) == CS_TEAM_CT && is_user_alive( client ) || get_user_flags( client ) & ADMIN_ACCESS )
  33.     {
  34.         if ( g_iGame[ client ] == 0 )
  35.             g_iGame[ client ]   = 1;
  36.        
  37.         return cmdMainMenu( client );
  38.     }
  39.    
  40.     if ( !is_user_alive( client ) )
  41.         return ColorPrint( client, "You need to be alive." );
  42.    
  43.     return ColorPrint( client, "You don't have access to this menu." );
  44. }
  45.  
  46. public cmdMainMenu( const client )
  47. {
  48.     if ( cs_get_user_team( client ) == CS_TEAM_CT && is_user_alive( client ) || get_user_flags( client ) & ADMIN_ACCESS )
  49.     {
  50.         static Menu;
  51.        
  52.         formatex( szItem, charsmax( szItem ), "\r[%s]\w Jailbreak Games", szPrefix );
  53.        
  54.         Menu    = menu_create( szItem, "handlerMainMenu" );
  55.        
  56.         formatex( szItem, charsmax( szItem ), "Select a Game:\r %s", szEvents[ g_iGame[ client ] ] );
  57.        
  58.         menu_additem( Menu, szItem );
  59.        
  60.         formatex( szItem, charsmax( szItem ), "%s%s\w Game", is_game_active() ? "\r" : "\y", is_game_active() ? "Stop" : "Start" );
  61.        
  62.         menu_additem( Menu, szItem );
  63.        
  64.         menu_display( client, Menu );
  65.        
  66.         return 1;
  67.     }
  68.    
  69.     if ( !is_user_alive( client ) )
  70.         return ColorPrint( client, "You need to be alive." );
  71.    
  72.     return ColorPrint( client, "You don't have access to this menu." );
  73. }
  74.  
  75. public handlerMainMenu( client, Menu, Item )
  76. {
  77.     if ( Item == MENU_EXIT )
  78.     {
  79.         menu_destroy( Menu );
  80.        
  81.         return 1;
  82.     }
  83.    
  84.     if ( cs_get_user_team( client ) == CS_TEAM_CT && is_user_alive( client ) || get_user_flags( client ) & ADMIN_ACCESS )
  85.     {
  86.         if ( Item == 0 )    // Switch games
  87.             return cmdSelectGameMenu( client );
  88.        
  89.         if ( Item == 1 )    // Stop\Start games
  90.         {
  91.            
  92.             if ( is_game_active() )
  93.             {
  94.                 ColorPrint( 0, "^3%s^1 has stopped the^4 %s^1 contest.", szName( client ), szEvents[ get_game_type() ] );
  95.                
  96.                 end_game( END_STOP );
  97.             }
  98.            
  99.             else
  100.             {
  101.                 start_game( g_iGame[ client ] );
  102.                
  103.                 ColorPrint( 0, "^3%s^1 has started a^4 %s^1 contest.", szName( client ), szEvents[ get_game_type() ] );
  104.             }
  105.         }
  106.        
  107.         return cmdMainMenu( client );
  108.     }
  109.    
  110.     if ( !is_user_alive( client ) )
  111.         return ColorPrint( client, "You need to be alive." );
  112.    
  113.     return ColorPrint( client, "You don't have access to this menu." );
  114. }
  115.  
  116. public cmdSelectGameMenu( const client )
  117. {
  118.     static Menu, i;
  119.    
  120.     formatex( szItem, charsmax( szItem ), "\r[%s]\w Jailbreak Games^n^nSelect a Game", szPrefix );
  121.    
  122.     Menu    = menu_create( szItem, "handlerSelectGameMenu" );
  123.    
  124.     for ( i = 1; i < sizeof szEvents; i++ )
  125.         menu_additem( Menu, szEvents[ i ] );
  126.    
  127.     menu_setprop( Menu, MPROP_EXITNAME, "Back" );
  128.    
  129.     menu_display( client, Menu );
  130.    
  131.     return 1;
  132. }
  133.  
  134. public handlerSelectGameMenu( client, Menu, Item )
  135. {
  136.     if ( Item == MENU_EXIT )
  137.     {
  138.         menu_destroy( Menu );
  139.        
  140.         return cmdMainMenu( client );
  141.     }
  142.    
  143.     g_iGame[ client ]   = Item + 1;
  144.    
  145.     return cmdMainMenu( client );
  146. }
Advertisement
Add Comment
Please, Sign In to add comment