Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- /*
- JailBreak MaxRounds for CT v1.2
- Copyright (C) 2012 NorToN
- This program is free software: you can redistribute it and/or modify
- it under the terms of the GNU General Public License as published by
- the Free Software Foundation, either version 3 of the License, or
- (at your option) any later version.
- This program is distributed in the hope that it will be useful,
- but WITHOUT ANY WARRANTY; without even the implied warranty of
- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- GNU General Public License for more details.
- You should have received a copy of the GNU General Public License
- along with this program. If not, see <http://www.gnu.org/licenses/>.
- */
- #include <amxmodx>
- #include <amxmisc>
- #include <cstrike>
- #pragma semicolon 1
- new g_Round[33];
- new g_MaxPlayers,g_Cvar,g_Cvar2;
- public plugin_init(){
- register_plugin("JB Max Rounds ( with API )","1.2","NorToN");
- register_clcmd("amx_rounds","cl_cmdrounds",_,"<name>");
- register_clcmd("say","HandleSay");
- register_clcmd("say_team","HandleSay");
- g_Cvar = register_cvar("amx_maxrounds","10");
- g_MaxPlayers = get_maxplayers();
- register_logevent("EventRoundEnd",2,"1=Round_End");
- set_task(70.0,"cmd_advmsg",_,_,_,"b");
- }
- public plugin_natives( )
- {
- register_native( "get_user_rounds", "_get_user_rounds" );
- register_native( "set_user_rounds", "_set_user_rounds" );
- }
- public _get_user_rounds( plugin, params )
- {
- return g_Round[ get_param( 1 ) ];
- }
- public _set_user_rounds( plugin, params )
- {
- g_Round[ get_param( 1 ) ] = max( 0, get_param( 2 ) );
- }
- public cmd_advmsg()
- for (new i = 1; i <= g_MaxPlayers;i++)
- ColorChat(i,"Type ^4/rounds^1 or ^4!rounds^1 to view how much rounds player X played in the CT team.");
- public client_putinserver(id) g_Round[id] = 0;
- public client_disconnect(id) g_Round[id] = 0;
- public EventRoundEnd(){
- g_Cvar2 = get_pcvar_num(g_Cvar);
- for (new i = 1; i <= g_MaxPlayers; i++)
- {
- if (!is_user_connected(i))
- continue;
- else if (cs_get_user_team(i) != CS_TEAM_CT)
- continue;
- g_Round[i]++;
- ColorChat(i,"You played: ^4%i/%i^1 rounds.",g_Round[i],g_Cvar2);
- if (g_Round[i] > g_Cvar2)
- {
- cs_set_user_team(i,CS_TEAM_T);
- ColorChat(i,"You reatch to your max rounds (^4%i^1)! You now moved to the ^3Terrorist^1 team!",g_Cvar2);
- g_Round[i] = 0;
- }
- }
- }
- public cl_cmdrounds(id){
- new Args[32],szName[32];
- read_argv(1,Args,charsmax(Args));
- if (equali(Args,""))
- {
- client_print(id,print_console,"Usage: amx_rounds <name>");
- return 1;
- }
- new player = cmd_target(id,Args,8);
- g_Cvar2 = get_pcvar_num(g_Cvar);
- if(!player)
- return 1;
- get_user_name(player,szName,charsmax(szName));
- if (cs_get_user_team(player) != CS_TEAM_CT)
- {
- client_print(id,print_console,"%s isn't in the Counter-Terrorist (CT) team!",szName);
- return 1;
- }
- else if (id == player)
- {
- client_print(id,print_console,"You played: %i/%i rounds.",g_Round[player],g_Cvar2);
- return 1;
- }
- client_print(id,print_console,"%s played: %i/%i rounds.",szName,g_Round[player],g_Cvar2);
- return 1;
- }
- public HandleSay(id){
- new Args[128],Args2[16],Args3[32],szName[32];
- read_argv(1,Args,charsmax(Args));
- parse(Args,Args2,charsmax(Args2),Args3,charsmax(Args3));
- if(equali(Args2,"/rounds") || equali(Args2,"!rounds"))
- {
- if (equali(Args3,""))
- {
- ColorChat(id,"Usage: ^4/rounds <name>^1 or ^4!rounds <name>^1");
- return 1;
- }
- new player = cmd_target(id,Args3,8);
- g_Cvar2 = get_pcvar_num(g_Cvar);
- if(!player)
- {
- ColorChat(id,"Player ^4%s^1 does not exist / isn't not connected!",Args3);
- return 1;
- }
- get_user_name(player,szName,charsmax(szName));
- if (cs_get_user_team(player) != CS_TEAM_CT)
- {
- ColorChat(id,"^4%s^1 isn't in the ^4Counter-Terrorist^1 (CT) team!",szName);
- return 1;
- }
- else if (id == player)
- {
- ColorChat(id,"You played: ^4%i/%i^1 rounds.",g_Round[player],g_Cvar2);
- return 1;
- }
- ColorChat(id,"^4%s^1 played: ^4%i/%i^1 rounds.",szName,g_Round[player],g_Cvar2);
- return 1;
- }
- return 0;
- }
- stock ColorChat(const id, const string[], {Float, Sql, Resul,_}:...){
- new msg[191], players[32], count = 1;
- static len; len = formatex(msg, charsmax(msg), "^x04[^x01 Galactic-Jail ^x04]^x01 ");
- vformat(msg[len], charsmax(msg) - len, string, 3);
- if(id) players[0] = id;
- else get_players(players,count,"ch");
- for (new i = 0; i < count; i++)
- {
- if(is_user_connected(players[i]))
- {
- message_begin(MSG_ONE_UNRELIABLE, get_user_msgid("SayText"),_, players[i]);
- write_byte(players[i]);
- write_string(msg);
- message_end();
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment