Guest User

Untitled

a guest
Dec 19th, 2012
237
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 4.72 KB | None | 0 0
  1. /*
  2. JailBreak MaxRounds for CT v1.2
  3. Copyright (C) 2012 NorToN
  4.  
  5. This program is free software: you can redistribute it and/or modify
  6. it under the terms of the GNU General Public License as published by
  7. the Free Software Foundation, either version 3 of the License, or
  8. (at your option) any later version.
  9.  
  10. This program is distributed in the hope that it will be useful,
  11. but WITHOUT ANY WARRANTY; without even the implied warranty of
  12. MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  13. GNU General Public License for more details.
  14.  
  15. You should have received a copy of the GNU General Public License
  16. along with this program. If not, see <http://www.gnu.org/licenses/>.
  17. */
  18.  
  19. #include <amxmodx>
  20. #include <amxmisc>
  21. #include <cstrike>
  22.  
  23. #pragma semicolon 1
  24.  
  25. new g_Round[33];
  26. new g_MaxPlayers,g_Cvar,g_Cvar2;
  27.  
  28. public plugin_init(){
  29. register_plugin("JB Max Rounds ( with API )","1.2","NorToN");
  30.  
  31. register_clcmd("amx_rounds","cl_cmdrounds",_,"<name>");
  32. register_clcmd("say","HandleSay");
  33. register_clcmd("say_team","HandleSay");
  34.  
  35. g_Cvar = register_cvar("amx_maxrounds","10");
  36. g_MaxPlayers = get_maxplayers();
  37.  
  38. register_logevent("EventRoundEnd",2,"1=Round_End");
  39.  
  40. set_task(70.0,"cmd_advmsg",_,_,_,"b");
  41. }
  42.  
  43. public plugin_natives( )
  44. {
  45. register_native( "get_user_rounds", "_get_user_rounds" );
  46. register_native( "set_user_rounds", "_set_user_rounds" );
  47. }
  48.  
  49. public _get_user_rounds( plugin, params )
  50. {
  51. return g_Round[ get_param( 1 ) ];
  52. }
  53.  
  54. public _set_user_rounds( plugin, params )
  55. {
  56. g_Round[ get_param( 1 ) ] = max( 0, get_param( 2 ) );
  57. }
  58.  
  59. public cmd_advmsg()
  60. for (new i = 1; i <= g_MaxPlayers;i++)
  61. ColorChat(i,"Type ^4/rounds^1 or ^4!rounds^1 to view how much rounds player X played in the CT team.");
  62.  
  63. public client_putinserver(id) g_Round[id] = 0;
  64. public client_disconnect(id) g_Round[id] = 0;
  65.  
  66. public EventRoundEnd(){
  67. g_Cvar2 = get_pcvar_num(g_Cvar);
  68. for (new i = 1; i <= g_MaxPlayers; i++)
  69. {
  70. if (!is_user_connected(i))
  71. continue;
  72.  
  73. else if (cs_get_user_team(i) != CS_TEAM_CT)
  74. continue;
  75.  
  76. g_Round[i]++;
  77.  
  78. ColorChat(i,"You played: ^4%i/%i^1 rounds.",g_Round[i],g_Cvar2);
  79.  
  80. if (g_Round[i] > g_Cvar2)
  81. {
  82. cs_set_user_team(i,CS_TEAM_T);
  83. ColorChat(i,"You reatch to your max rounds (^4%i^1)! You now moved to the ^3Terrorist^1 team!",g_Cvar2);
  84. g_Round[i] = 0;
  85. }
  86. }
  87. }
  88.  
  89. public cl_cmdrounds(id){
  90. new Args[32],szName[32];
  91. read_argv(1,Args,charsmax(Args));
  92.  
  93. if (equali(Args,""))
  94. {
  95. client_print(id,print_console,"Usage: amx_rounds <name>");
  96. return 1;
  97. }
  98.  
  99. new player = cmd_target(id,Args,8);
  100. g_Cvar2 = get_pcvar_num(g_Cvar);
  101.  
  102. if(!player)
  103. return 1;
  104.  
  105. get_user_name(player,szName,charsmax(szName));
  106.  
  107.  
  108. if (cs_get_user_team(player) != CS_TEAM_CT)
  109. {
  110. client_print(id,print_console,"%s isn't in the Counter-Terrorist (CT) team!",szName);
  111. return 1;
  112. }
  113.  
  114. else if (id == player)
  115. {
  116. client_print(id,print_console,"You played: %i/%i rounds.",g_Round[player],g_Cvar2);
  117. return 1;
  118. }
  119.  
  120. client_print(id,print_console,"%s played: %i/%i rounds.",szName,g_Round[player],g_Cvar2);
  121. return 1;
  122. }
  123.  
  124.  
  125. public HandleSay(id){
  126. new Args[128],Args2[16],Args3[32],szName[32];
  127. read_argv(1,Args,charsmax(Args));
  128. parse(Args,Args2,charsmax(Args2),Args3,charsmax(Args3));
  129. if(equali(Args2,"/rounds") || equali(Args2,"!rounds"))
  130. {
  131. if (equali(Args3,""))
  132. {
  133. ColorChat(id,"Usage: ^4/rounds <name>^1 or ^4!rounds <name>^1");
  134. return 1;
  135. }
  136. new player = cmd_target(id,Args3,8);
  137. g_Cvar2 = get_pcvar_num(g_Cvar);
  138.  
  139. if(!player)
  140. {
  141. ColorChat(id,"Player ^4%s^1 does not exist / isn't not connected!",Args3);
  142. return 1;
  143. }
  144.  
  145. get_user_name(player,szName,charsmax(szName));
  146.  
  147.  
  148. if (cs_get_user_team(player) != CS_TEAM_CT)
  149. {
  150. ColorChat(id,"^4%s^1 isn't in the ^4Counter-Terrorist^1 (CT) team!",szName);
  151. return 1;
  152. }
  153.  
  154. else if (id == player)
  155. {
  156. ColorChat(id,"You played: ^4%i/%i^1 rounds.",g_Round[player],g_Cvar2);
  157. return 1;
  158. }
  159.  
  160. ColorChat(id,"^4%s^1 played: ^4%i/%i^1 rounds.",szName,g_Round[player],g_Cvar2);
  161. return 1;
  162. }
  163.  
  164. return 0;
  165. }
  166.  
  167. stock ColorChat(const id, const string[], {Float, Sql, Resul,_}:...){
  168. new msg[191], players[32], count = 1;
  169.  
  170. static len; len = formatex(msg, charsmax(msg), "^x04[^x01 Galactic-Jail ^x04]^x01 ");
  171. vformat(msg[len], charsmax(msg) - len, string, 3);
  172.  
  173. if(id) players[0] = id;
  174. else get_players(players,count,"ch");
  175.  
  176. for (new i = 0; i < count; i++)
  177. {
  178. if(is_user_connected(players[i]))
  179. {
  180. message_begin(MSG_ONE_UNRELIABLE, get_user_msgid("SayText"),_, players[i]);
  181. write_byte(players[i]);
  182. write_string(msg);
  183. message_end();
  184. }
  185. }
  186. }
Advertisement
Add Comment
Please, Sign In to add comment