Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- /* Plugin generated by AMXX-Studio */
- #include < amxmodx >
- #include < amxmisc >
- #include < cstrike >
- #include < hamsandwich >
- #define MAX_ROUNDS 15
- new iRounds[ 33 ], szText[ 128 ];
- new const GetCommands[ ] [ ] = { "say /getmenu", "say_team /getmenu", "say /get", "say_team /get" }
- public plugin_init()
- {
- register_plugin( "CT Rounds", "1.0", "Xdoctor" );
- register_clcmd( "say", "CmdHandleSay" );
- register_clcmd( "say_team", "CmdHandleSay" );
- RegisterHam( Ham_Spawn, "player", "fwClientSpawn" );
- for( new i = 0; i < sizeof( GetCommands ); i++ )
- register_clcmd( GetCommands[ i ], "GetMenu" );
- }
- public client_disconnect( client )
- iRounds[ client ] = 0;
- public fwClientSpawn( client )
- {
- if( !is_user_alive( client ) )
- return 1;
- iRounds[ client ] += 1;
- if( cs_get_user_team( client ) != CS_TEAM_T && GetUserRounds( client ) <= MAX_ROUNDS )
- return ColorChat( 0, "You are on your ^4%i^1/^4%i^1 Round ^1( ^4%s Rounds left^1 )", GetUserRounds( client ), MAX_ROUNDS, GetUserLeftRounds( client ) );
- if( GetUserRounds( client ) >= MAX_ROUNDS && cs_get_user_team( client ) == CS_TEAM_CT )
- {
- cs_set_user_team( client, CS_TEAM_T )
- ExecuteHamB( Ham_CS_RoundRespawn, client );
- iRounds[ client ] = 0;
- ColorChat( client, "Your time has a CT is up!" )
- }
- return 1;
- }
- public GetMenu( client )
- {
- if( cs_get_user_team( client ) != CS_TEAM_CT )
- return ColorChat( client, "Only guards can use this command" );
- formatex( szText, charsmax( szText ), "\d[ \yAMXX\d ]\y GetMenu\w:" )
- new Menu = menu_create( szText, "CmdGetMenuHandler" );
- new players[ 32 ], pnum;
- get_players( players, pnum );
- for( new i = 0; i < pnum; i++ )
- {
- if( !is_user_connected( i ) || cs_get_user_team( i ) != CS_TEAM_T )
- continue;
- formatex( szText, charsmax( szText ), "\rPlayer\w:\y %s\d.", GetUserName( i ) );
- menu_additem( Menu, szText );
- }
- menu_display( client, Menu, 0 );
- return 1;
- }
- public CmdGetMenuHandler( client, Menu, Item )
- {
- if( Item >= MENU_EXIT )
- {
- menu_destroy( Menu );
- return 1;
- }
- new szName [ 33 ], iAccess, Data[ 8 ], iCallback;
- menu_item_getinfo( Menu, Item, iAccess, Data, 6, szName, charsmax( szName ), iCallback );
- new cPlayer = str_to_num( Data );
- SendGetRequest( client, cPlayer );
- return 1;
- }
- public SendGetRequest( cPlayer, client )
- {
- formatex( szText, charsmax( szText ), "\yWould you like to switch teams with %s \w?", GetUserName( client ) );
- new Menu = menu_create( szText, "CmdGetAnswer" );
- menu_additem( Menu, "\wYes I Want", "0" );
- menu_additem( Menu, "\wNah Im good", "1" );
- menu_display( client, Menu, 0 );
- return 1;
- }
- public CmdGetAnswer( cPlayer, Menu, Item )
- {
- if( Item >= MENU_EXIT )
- {
- menu_destroy( Menu );
- return 1;
- }
- new Data[ 6 ], szName2[ 32 ], szKey[ 10 ], iClient[ 10 ], Access, iCallback;
- menu_item_getinfo( Menu, Item, Access, Data, charsmax( Data ), szName2, charsmax( szName2 ), iCallback );
- parse( Data, szKey, charsmax( szKey ), iClient, charsmax( iClient ) );
- new iKey = str_to_num( szKey );
- new client = str_to_num( iClient );
- switch( iKey )
- {
- case 0:
- {
- cs_set_user_team( cPlayer, CS_TEAM_CT );
- cs_set_user_team( client, CS_TEAM_T );
- ExecuteHamB( Ham_CS_RoundRespawn, cPlayer );
- ExecuteHamB( Ham_CS_RoundRespawn, cPlayer );
- iRounds[ cPlayer ] = GetUserRounds( client );
- iRounds[ client ] = 0;
- ColorChat( 0, "The Guard: ^4%s^1 switched teams with the Prisoner:^4 %s", GetUserName( cPlayer ), GetUserName( client ) );
- ColorChat( cPlayer, "The Player^4 %s^1. rounds has been Transfor for You", GetUserName( client ) );
- }
- case 1: return ColorChat( client, "The Player:^4 %s^1 denied your Request to switch Teams!!", GetUserName( cPlayer ) );
- }
- return 1;
- }
- public CmdHandleSay( client )
- {
- new szMsg[ 128 ], iPlayer[ 33 ], szPlayer, Amount;
- read_argv( 1, szMsg, charsmax( szMsg ) );
- if( equali( szMsg, "/rounds" ) )
- {
- for( new i = 1; i < get_maxplayers(); i++ )
- {
- if( !is_user_connected( i ) )
- continue;
- szPlayer = cmd_target( client, iPlayer, CMDTARGET_NO_BOTS )
- }
- if( cs_get_user_team( szPlayer ) != CS_TEAM_CT )
- return ColorChat( client, "This player isn't a guard" );
- if( !szPlayer )
- return ColorChat( client, "Target not found!" )
- if( szPlayer )
- return ColorChat( client, "The Guard :^4 %s^1 In is ^4%i^1/^4%i^1 Round ( ^4He has %i Rounds left^1 )", GetUserRounds( szPlayer ), MAX_ROUNDS, GetUserLeftRounds( szPlayer) );
- }
- Amount = str_to_num( szMsg );
- if( equali( szMsg, "/addrounds" ) )
- {
- if( !is_user_admin( client ) )
- return ColorChat( client, "This command can be used only by an admin!" );
- if( !szPlayer )
- return ColorChat( client, "Target not found!" )
- if( GetUserRounds( szPlayer ) > MAX_ROUNDS - 1 )
- return ColorChat( client, "Play must have less then One Round left to use this command on am." )
- iRounds[ szPlayer ] += Amount;
- }
- return 1;
- }
- stock GetUserLeftRounds( const Index )
- return MAX_ROUNDS - iRounds[ Index ];
- stock GetUserRounds( const Index )
- return iRounds[ Index ];
- stock GetUserName( const Index )
- {
- static szName[ 32 ];
- get_user_name( Index, szName, charsmax( szName ) );
- return szName;
- }
- stock ColorChat( const id, const string[], any:... )
- {
- new msg[191], players[32], count = 1;
- static len; len = formatex(msg, charsmax(msg), "^1[ ^4AMXX^1 ] " );
- 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();
- }
- }
- return 1;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement