Advertisement
Guest User

Auto Switch Team Color

a guest
Oct 28th, 2018
79
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 4.50 KB | None | 0 0
  1. /********************************************************************************
  2. * Auto Team Switch Every X Rounds By *
  3. * *
  4. * Author: nikhilgupta345 *
  5. * ------------------------------------------------------------------------ *
  6. * Info: *
  7. * This plugin allows you to switch sides of teams every set number *
  8. * of rounds. Also gives a command to restart the number of rounds played. * *
  9. * ------------------------------------------------------------------------ *
  10. * Cvars: *
  11. * amx_atsrounds - sets the number of rounds before a team switch occurs. *
  12. * ------------------------------------------------------------------------ *
  13. * Commands: *
  14. * amx_roundrestart - restarts the number of rounds that have been played. *
  15. * say /roundnumber - displays the amount of rounds that have been played. *
  16. * ------------------------------------------------------------------------ *
  17. * Credits: *
  18. * Nextra - Giving suggestions and making the code more efficient. *
  19. * Tirant - Giving suggestions as well and providing code for the delay. *
  20. * Connormcleod - Final suggestions on optimizing code. *
  21. * ------------------------------------------------------------------------ *
  22. * Changelog: *
  23. * v1.0 - Initial release *
  24. * v1.01 - Fixed Bugs - Optimized Code *
  25. * v1.1 - Fixed crashing with certain amount of people. *********************************
  26. * v1.1.1 - Added new client command - /roundnumber, which displays the amount of rounds that have passed. *
  27. * v1.2 - Further optimized. Changed name of cvar to make it easier to remember. Added comments. *
  28. * *
  29. * Plugin Main Thread: http://forums.alliedmods.net/showthread.php?p=1288262 *
  30. * *
  31. ****************************************************************************************************************/
  32.  
  33. #include <amxmodx>
  34. #include <amxmisc>
  35. #include <cstrike>
  36.  
  37. #define PLUGIN "Auto Team Switcher"
  38. #define VERSION "1.0"
  39. #define AUTHOR "nikhilgupta345"
  40.  
  41. #pragma semicolon 1
  42.  
  43. new roundnumber = 0;
  44. new Atsround;
  45.  
  46. public plugin_init()
  47. {
  48. register_plugin(PLUGIN, VERSION, AUTHOR);
  49.  
  50. register_clcmd( "say /roundnumber", "sayRound" );
  51. register_concmd( "amx_roundrestart", "restartnumber", ADMIN_MAP );
  52.  
  53. register_logevent( "roundend", 2, "1=Round_End" );
  54. register_event( "TextMsg","restart","a","2&#Game_C", "2&#Game_W" ); // Event for "Game Commencing" TextMsg and "Game Will Restart in X Seconds" TextMsg
  55.  
  56. Atsround = register_cvar( "amx_atsrounds", "3" );
  57.  
  58. }
  59.  
  60. public sayRound( id )
  61. {
  62. client_print( id, print_chat, "The current round is %i.", roundnumber );
  63. return PLUGIN_HANDLED;
  64. }
  65.  
  66. public roundend()
  67. {
  68. roundnumber++;
  69.  
  70. if( roundnumber >= get_pcvar_num( Atsround ) )
  71. {
  72. new players[32], num;
  73. get_players( players, num );
  74.  
  75. for( new i; i < num; i++ )
  76. add_delay( players[i] ); // Prevent Server Crash with a lot of people.
  77.  
  78. }
  79. }
  80.  
  81.  
  82. public restartnumber( id, level, cid )
  83. {
  84. if( !cmd_access( id, level, cid, 1 ) )
  85. return PLUGIN_HANDLED;
  86.  
  87. roundnumber = 0;
  88. return PLUGIN_HANDLED;
  89. }
  90.  
  91. public restart( id )
  92. {
  93. roundnumber = 0;
  94. return PLUGIN_HANDLED;
  95. }
  96.  
  97. public changeTeam( id )
  98. {
  99. switch( cs_get_user_team( id ) )
  100. {
  101. case CS_TEAM_CT: cs_set_user_team( id, CS_TEAM_T );
  102.  
  103. case CS_TEAM_T: cs_set_user_team( id, CS_TEAM_CT );
  104. }
  105.  
  106. roundnumber = 0;
  107. }
  108.  
  109. add_delay( id )
  110. {
  111. switch( id )
  112. {
  113. case 1..7: set_task( 0.1, "changeTeam", id );
  114. case 8..15: set_task( 0.2, "changeTeam", id );
  115. case 16..23: set_task( 0.3, "changeTeam", id );
  116. case 24..32: set_task( 0.4, "changeTeam", id );
  117. }
  118. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement