iXdoctor

Countdown System for Jailbreak

Sep 5th, 2014
424
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Pawn 4.95 KB | None | 0 0
  1. /* Plugin generated by AMXX-Studio */
  2.  
  3. #include < amxmodx >
  4. #include < fakemeta >
  5. #include < cstrike >
  6.  
  7. #define MAX_SECONDS 90
  8.  
  9. #define COUNT_TASK  17
  10.  
  11. new const szTeams_Freeze [ ] [ ] =
  12. {
  13.     "All Team's",
  14.     "Terrorist's",
  15.     "Counter Terrorist's",
  16.     "None"
  17. }
  18.  
  19. new iSound[ 33 ], iVoice[ 33 ], iFreeze[ 33 ], iSeconds[ 33 ] = 5, Countdown_Time, gCountStarted;
  20.  
  21. public plugin_init()
  22. {
  23.     register_plugin( "Countdown Menu", "1.0", "Doctor Who ?" );
  24.    
  25.     register_clcmd( "say /cd", "Countdown_Menu" );
  26. }
  27.  
  28. public Countdown_Menu( client )
  29. {
  30.     if( !is_user_alive( client ) )
  31.         return ColorChat( client, "^4%s^1 You ^3need ^1to be ^4alive^1 to ^4use^1 this ^3command^1.", GetUserName( client ) )
  32.        
  33.     if( cs_get_user_team( client ) != CS_TEAM_CT )
  34.         return ColorChat( client, "^4%s^1 You ^4need^1 to ^4be^1 a ^3counter ^1- ^3terrorist ^1alive ^3player. ", GetUserName( client ) );
  35.        
  36.     new szText[ 192 ];
  37.    
  38.     formatex( szText, charsmax( szText ), "\d[ \yAMXX\d ] \wCountdown Menu\d:" );
  39.    
  40.     new Menu = menu_create( szText, "Countdown_Handler" );
  41.    
  42.     formatex( szText, charsmax( szText ), "\wCountdown Seconds - \d%i", iSeconds[ client ] );
  43.    
  44.     menu_additem( Menu, szText );
  45.    
  46.     formatex( szText, charsmax( szText ), "\wCountdown Freeze - \d%s", szTeams_Freeze[ iFreeze[ client ] ] );
  47.    
  48.     menu_additem( Menu, szText );
  49.    
  50.     formatex( szText, charsmax( szText ), "\wCountdown Sound - \d%s", iSound[ client ] ? "ON" : "OFF" );
  51.    
  52.     menu_additem( Menu, szText );
  53.    
  54.     formatex( szText, charsmax( szText ), "\wCountdown Voice - \d%s", iVoice[ client ]  ? "Male" : "Female" );
  55.    
  56.     menu_additem( Menu, szText );
  57.    
  58.     formatex( szText, charsmax( szText ), "\w%s the Countdown.", gCountStarted ? "Stop" : "Start" );
  59.    
  60.     menu_display( client, Menu, 0 );
  61.    
  62.     return 1;
  63. }
  64.  
  65. public Countdown_Handler( client, Menu, Item )
  66. {
  67.     if( Item == MENU_EXIT )
  68.     {
  69.         menu_destroy( Menu );
  70.        
  71.         return 1;
  72.     }
  73.    
  74.     switch( Item )
  75.     {
  76.         case 0:
  77.         {
  78.             if( iSeconds[ client ] >= MAX_SECONDS )
  79.                 iSeconds[ client ] = 5;
  80.            
  81.             else
  82.                 iSeconds[ client ] += 5;
  83.         }
  84.        
  85.         case 1:
  86.         {
  87.             if( iFreeze[ client ] >= sizeof( szTeams_Freeze ) -1 )
  88.                 iFreeze[ client ] = 0;
  89.            
  90.             else
  91.                 iFreeze[ client ] += 1;
  92.         }
  93.        
  94.         case 2: iSound[ client ] = !iSound[ client ];
  95.        
  96.         case 3: iVoice[ client ] = !iVoice[ client ];
  97.        
  98.         case 4:
  99.         {
  100.             if( gCountStarted )
  101.             {
  102.                 ColorChat( 0, "^4%s^1 has ^4stopped^1 the ^3countdown.", GetUserName( client ) );
  103.                
  104.                 gCountStarted = false;
  105.                
  106.                 remove_task( COUNT_TASK );
  107.                
  108.                 for( new i; i < get_maxplayers(); i++ )
  109.                 {
  110.                     if( !is_user_connected( i ) )
  111.                         continue;
  112.                        
  113.                     set_user_freeze( i, 0 );
  114.                 }
  115.             }
  116.            
  117.             gCountStarted = true;
  118.            
  119.             Countdown_Time = iSeconds[ client ];
  120.            
  121.             set_task( 1.0, "CmdCountdown", client + COUNT_TASK, _,_, "b" );
  122.            
  123.             FreezePlayers( client );
  124.            
  125.             return menu_destroy( Menu );
  126.         }
  127.     }
  128.    
  129.     return Countdown_Menu( client );
  130. }
  131.  
  132. public FreezePlayers( client )
  133. {
  134.     for( new i = 0; i < get_maxplayers(); i++ )
  135.     {
  136.         if( !is_user_alive( i ) )
  137.             continue;
  138.            
  139.         switch( iFreeze[ client ] )
  140.         {
  141.             case 0:                             set_user_freeze( i, 1 );
  142.             case 1: if( cs_get_user_team( i ) == CS_TEAM_T )            set_user_freeze( i, 1 );
  143.             case 2: if( cs_get_user_team( i ) == CS_TEAM_CT )       set_user_freeze( i, 1 );
  144.             case 3:                             set_user_freeze( i, 0 );
  145.         }
  146.     }      
  147. }
  148.  
  149. public CmdCountdown( client )
  150. {
  151.     if( Countdown_Time <= 0 )
  152.     {
  153.         for( new i; i < get_maxplayers(); i++ )
  154.         {
  155.             if( !is_user_connected( i ) )
  156.                 continue;
  157.                
  158.             set_user_freeze( i, 0 );
  159.         }
  160.        
  161.         gCountStarted = false;
  162.        
  163.         ColorChat( 0, "The ^3Countdown has ^3ended." );
  164.        
  165.         remove_task( COUNT_TASK );
  166.     }
  167.    
  168.     set_hudmessage( 0, 255, 255, -1.0, 0.46, 0, 6.0, 1.0 )
  169.    
  170.     show_hudmessage( 0, "Countdown have left %i seconds", Countdown_Time )
  171.    
  172.     Countdown_Time -= 1;
  173.    
  174.     if( Countdown_Time < 21 && iSound[ client ] )
  175.     {
  176.         new szVox[ 10 ];
  177.        
  178.         num_to_word( Countdown_Time, szVox, charsmax( szVox ) );
  179.        
  180.         if( iVoice[ client ] ) client_cmd( 0, "spk ^"vox/%s^"", szVox );
  181.         if( !iVoice[ client ] ) client_cmd( 0, "spk ^"fvox/%s^"", szVox );
  182.     }
  183. }
  184.    
  185. stock GetUserName( index )
  186. {
  187.     new szName[ 32 ];
  188.    
  189.     get_user_name( index, szName, charsmax( szName ) );
  190.    
  191.     return szName;
  192. }
  193.  
  194. stock set_user_freeze( index, freeze )
  195. {
  196.     new iFlag = pev( index, pev_flags );
  197.    
  198.     set_pev( index, pev_flags, freeze ? iFlag | FL_FROZEN : iFlag & ~FL_FROZEN );
  199. }
  200.  
  201. stock ColorChat(const id, const string[], {Float, Sql, Resul,_}:...)
  202. {
  203.     new msg[191], players[32], count = 1
  204.     static len
  205.     len = formatex(msg, charsmax(msg), "^1[ ^4Countdown - System^1 ] ")
  206.     vformat(msg[len], charsmax(msg) - len, string, 3)
  207.     if(id)    players[0] = id
  208.     else    get_players(players,count,"ch")
  209.    
  210.     for (new i = 0; i < count; i++)
  211.     {
  212.         if(is_user_connected(players[i]))
  213.         {
  214.             message_begin(MSG_ONE_UNRELIABLE, get_user_msgid("SayText"),_, players[i])
  215.             write_byte(players[i])
  216.             write_string(msg)
  217.             message_end()
  218.         }
  219.     }
  220.    
  221.     return 1;
  222. }
Advertisement
Add Comment
Please, Sign In to add comment