Raised This Month: $32 Target: $400
 8% 

Switch Teams Add color message pls


Post New Thread Reply   
 
Thread Tools Display Modes
Author Message
Godofwar
AlliedModders Donor
Join Date: Dec 2015
Location: Germany
Old 10-28-2018 , 04:40   Switch Teams Add color message pls
Reply With Quote #1

Hello can anyone add an colored message when the round max 5 is reached as example like:

^green^5 Rounds ^normal color^ reached. ^green^Switching Teams now.

It would be cool.


Code:
/********************************************************************************
*                        Auto Team Switch Every X Rounds By                     *
*                                                                               *
* Author: nikhilgupta345                                                        *
* ------------------------------------------------------------------------      *
* Info:                                                                         *
* This plugin allows you to switch sides of teams every set number              *
* of rounds. Also gives a command to restart the number of rounds played.       *													  	  		*
* ------------------------------------------------------------------------      *
* Cvars:                                                                        *
* amx_atsrounds - sets the number of rounds before a team switch occurs.        *
* ------------------------------------------------------------------------      *
* Commands:                                                                     *
* amx_roundrestart - restarts the number of rounds that have been played.       *
* say /roundnumber - displays the amount of rounds that have been played.       *
* ------------------------------------------------------------------------      *
* Credits:                                                                      *
* Nextra - Giving suggestions and making the code more efficient.               *
* Tirant - Giving suggestions as well and providing code for the delay.	        *
* Connormcleod - Final suggestions on optimizing code.                          *
* ------------------------------------------------------------------------      *
* Changelog:                                                                    *
* v1.0 - Initial release                                                        *
* v1.01 - Fixed Bugs - Optimized Code                                           *
* v1.1 - Fixed crashing with certain amount of people.                          *********************************
* v1.1.1 - Added new client command - /roundnumber, which displays the amount of rounds that have passed.       *
* v1.2 - Further optimized. Changed name of cvar to make it easier to remember. Added comments.                 *
*                                                                                                               *
* Plugin Main Thread: http://forums.alliedmods.net/showthread.php?p=1288262                                     *
*                                                                                                               *
****************************************************************************************************************/
	
#include <amxmodx>
#include <amxmisc>
#include <cstrike>

#define PLUGIN "Auto Team Switcher"
#define VERSION "1.0"
#define AUTHOR "nikhilgupta345"

#pragma semicolon 1

new roundnumber = 0;
new Atsround;

public plugin_init() 
{
	register_plugin(PLUGIN, VERSION, AUTHOR);
	
	register_clcmd( "say /roundnumber", "sayRound" );
	register_concmd( "amx_roundrestart", "restartnumber", ADMIN_MAP );
	
	register_logevent( "roundend", 2, "1=Round_End" );
	register_event( "TextMsg","restart","a","2&#Game_C", "2&#Game_W" ); // Event for "Game Commencing" TextMsg and "Game Will Restart in X Seconds" TextMsg
	
	Atsround = register_cvar( "amx_atsrounds", "3" );
	
}

public sayRound( id )
{
	client_print( id, print_chat, "The current round is %i.", roundnumber );
	return PLUGIN_HANDLED;
}

public roundend()
{
	roundnumber++;
	
	if( roundnumber >= get_pcvar_num( Atsround ) )
	{
		new players[32], num;
		get_players( players, num );
		
		for( new i; i < num; i++ )
			add_delay( players[i] ); // Prevent Server Crash with a lot of people.
			
	}
}


public restartnumber( id, level, cid )
{
	if( !cmd_access( id, level, cid, 1 ) )
		return PLUGIN_HANDLED;
	
	roundnumber = 0;
	return PLUGIN_HANDLED;
}

public restart( id )
{
	roundnumber = 0;
	return PLUGIN_HANDLED;
}

public changeTeam( id )
{
	switch( cs_get_user_team( id ) )
	{
		case CS_TEAM_CT: cs_set_user_team( id, CS_TEAM_T );
		
		case CS_TEAM_T: cs_set_user_team( id, CS_TEAM_CT );
	}

	roundnumber = 0;
}

add_delay( id )
{
	switch( id )
	{
		case 1..7: set_task( 0.1, "changeTeam", id );
		case 8..15: set_task( 0.2, "changeTeam", id );
		case 16..23: set_task( 0.3, "changeTeam", id );
		case 24..32: set_task( 0.4, "changeTeam", id );
	}
}

Last edited by Godofwar; 10-28-2018 at 04:41.
Godofwar is offline
Nutu_
AlliedModders Donor
Join Date: Mar 2016
Location: Germany
Old 10-28-2018 , 05:24   Re: Switch Teams Add color message pls
Reply With Quote #2

Code:
stock player_color( const id, const input[ ], any:... )
{
	new count = 1, players[ 32 ]

	static msg[ 191 ]
	vformat( msg, 190, input, 3 )
	
	replace_all( msg, 190, "!g", "^4" ) /* verde */
	replace_all( msg, 190, "!n", "^1" ) /* galben */
	replace_all( msg, 190, "!t", "^3" ) /* ct=albastru | t=rosu */
	replace_all( msg, 190, "!e", "^0" ) /* normal-echipa */
	
	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( );
			}
		}
	}
Code:
player_color(0, !gRounds!n reached !gSwitching Teams now)
__________________
a simple act of caring creates an endless ripple.
Nutu_ is offline
Godofwar
AlliedModders Donor
Join Date: Dec 2015
Location: Germany
Old 10-28-2018 , 05:30   Re: Switch Teams Add color message pls
Reply With Quote #3

Code:
player_color(0, !gRounds!n reached !gSwitching Teams now)
Where i have to add this ...
Godofwar is offline
Nutu_
AlliedModders Donor
Join Date: Mar 2016
Location: Germany
Old 10-28-2018 , 06:17   Re: Switch Teams Add color message pls
Reply With Quote #4

well i guess it should be here
Code:
switch( cs_get_user_team( id ) )
	{
		case CS_TEAM_CT: cs_set_user_team( id, CS_TEAM_T );
		
		case CS_TEAM_T: cs_set_user_team( id, CS_TEAM_CT );
	}
but i tried to put there, got error for multiple cases, i tried use
Code:
if
else if
but still got errors, wait for others ;)
__________________
a simple act of caring creates an endless ripple.
Nutu_ is offline
Mr Misw
Member
Join Date: Aug 2018
Location: India
Old 10-28-2018 , 07:04   Re: Switch Teams Add color message pls
Reply With Quote #5

For 1.8.2
Use This
PHP Code:
#include <amxmodx>
#include <amxmisc>
#include <cstrike>

#define PLUGIN "Auto Team Switcher"
#define VERSION "1.0"
#define AUTHOR "nikhilgupta345"

new roundnumber 0;
new 
Atsround;

public 
plugin_init() 
{
    
register_plugin(PLUGINVERSIONAUTHOR);
    
    
register_clcmd"say /roundnumber""sayRound" );
    
register_concmd"amx_roundrestart""restartnumber"ADMIN_MAP );
    
    
register_logevent"roundend"2"1=Round_End" );
    
register_event"TextMsg","restart","a","2&#Game_C""2&#Game_W" );
    
    
Atsround register_cvar"amx_atsrounds""3" );
    
}

public 
sayRoundid )
{
    
client_print_colorid,  "^4The current ^3round ^1is ^4%i."roundnumber );
    return 
PLUGIN_HANDLED;
}

public 
roundend()
{
    
roundnumber++;
    
    if( 
roundnumber >= get_pcvar_numAtsround ) )
    {
        new 
players[32], num;
        
get_playersplayersnum );
        
        for( new 
inumi++ )
        {
            
            
add_delayplayers[i] ); 
        }
        
client_print_color,"^4Round ^1Reached ^4... ^3Switching Team Now . " );
    }
}

public 
restartnumberidlevelcid )
{
    if( !
cmd_accessidlevelcid) )
        return 
PLUGIN_HANDLED;
    
    
roundnumber 0;
    return 
PLUGIN_HANDLED;
}

public 
restartid )
{
    
roundnumber 0;
    return 
PLUGIN_HANDLED;
}

public 
changeTeamid )
{
    switch( 
cs_get_user_teamid ) )
    {
        case 
CS_TEAM_CTcs_set_user_teamidCS_TEAM_T );
        
        case 
CS_TEAM_Tcs_set_user_teamidCS_TEAM_CT );
    }

    
roundnumber 0;
}

add_delayid )
{
    switch( 
id )
    {
        case 
1..7set_task0.1"changeTeam"id );
        case 
8..15set_task0.2"changeTeam"id );
        case 
16..23set_task0.3"changeTeam"id );
        case 
24..32set_task0.4"changeTeam"id );
    }
}

stock client_print_color(const id, const input[], any:...)
{
    new 
count 1players[32]
    static 
msg[191]
    
vformat(msg190input3)
    
    
replace_all(msg190"!g""^4")
    
replace_all(msg190"!y""^1")
    
replace_all(msg190"!t""^3")
    
replace_all(msg190"!t2""^0")
    
    if (
idplayers[0] = id; else get_players(playerscount"ch")

    for (new 
0counti++)
    {
        if (
is_user_connected(players[i]))
        {
            
message_begin(MSG_ONE_UNRELIABLEget_user_msgid("SayText"), _players[i])
            
write_byte(players[i])
            
write_string(msg)
            
message_end()
        }
    }

For 1.8.3
Use This
PHP Code:
#include <amxmodx>
#include <amxmisc>
#include <cstrike>

#define PLUGIN "Auto Team Switcher"
#define VERSION "1.0"
#define AUTHOR "nikhilgupta345"

new roundnumber 0;
new 
Atsround;

public 
plugin_init() 
{
    
register_plugin(PLUGINVERSIONAUTHOR);
    
    
register_clcmd"say /roundnumber""sayRound" );
    
register_concmd"amx_roundrestart""restartnumber"ADMIN_MAP );
    
    
register_logevent"roundend"2"1=Round_End" );
    
register_event"TextMsg","restart","a","2&#Game_C""2&#Game_W" );
    
    
Atsround register_cvar"amx_atsrounds""3" );
    
}

public 
sayRoundid )
{
    
client_print_coloridid ,   "^4The current ^3round ^1is ^4%i."roundnumber );
    return 
PLUGIN_HANDLED;
}

public 
roundend()
{
    
roundnumber++;
    
    if( 
roundnumber >= get_pcvar_numAtsround ) )
    {
        new 
players[32], num;
        
get_playersplayersnum );
        
        for( new 
inumi++ )
        {
            
            
add_delayplayers[i] ); 
        }
        
client_print_color0,"^4Round ^1Reached ^4... ^3Switching Team Now . " );
    }
}

public 
restartnumberidlevelcid )
{
    if( !
cmd_accessidlevelcid) )
        return 
PLUGIN_HANDLED;
    
    
roundnumber 0;
    return 
PLUGIN_HANDLED;
}

public 
restartid )
{
    
roundnumber 0;
    return 
PLUGIN_HANDLED;
}

public 
changeTeamid )
{
    switch( 
cs_get_user_teamid ) )
    {
        case 
CS_TEAM_CTcs_set_user_teamidCS_TEAM_T );
        
        case 
CS_TEAM_Tcs_set_user_teamidCS_TEAM_CT );
    }

    
roundnumber 0;
}

add_delayid )
{
    switch( 
id )
    {
        case 
1..7set_task0.1"changeTeam"id );
        case 
8..15set_task0.2"changeTeam"id );
        case 
16..23set_task0.3"changeTeam"id );
        case 
24..32set_task0.4"changeTeam"id );
    }

__________________
Facebook ==> Here
ScrewedUP's Website :
Main Website
My Ranking System [Skin Version] :
ScrewedUP Ranking System
My Ranking System [Without Skin Version] :
ScrewedUP Ranking System
Mr Misw is offline
Godofwar
AlliedModders Donor
Join Date: Dec 2015
Location: Germany
Old 10-28-2018 , 07:36   Re: Switch Teams Add color message pls
Reply With Quote #6

Thx but its bugged for 1.8.3 it change the team after 4 rounds but i want that it change to 25...



Code:
#include <amxmodx>
#include <amxmisc>
#include <cstrike>

#define PLUGIN "Auto Team Switcher"
#define VERSION "1.0"
#define AUTHOR "nikhilgupta345"

new roundnumber = 0;
new Atsround;

public plugin_init() 
{
    register_plugin(PLUGIN, VERSION, AUTHOR);
    
    register_clcmd( "say /roundnumber", "sayRound" );
    register_concmd( "amx_roundrestart", "restartnumber", ADMIN_MAP );
    
    register_logevent( "roundend", 2, "1=Round_End" );
    register_event( "TextMsg","restart","a","2&#Game_C", "2&#Game_W" );
    
    Atsround = register_cvar( "amx_atsrounds", "25" );
    
}

public sayRound( id )
{
    client_print_color( id, id ,   "^4The current ^3round ^1is ^4%i.", roundnumber );
    return PLUGIN_HANDLED;
}

public roundend()
{
    roundnumber++;
    
    if( roundnumber >= get_pcvar_num( Atsround ) )
    {
        new players[32], num;
        get_players( players, num );
        
        for( new i; i < num; i++ )
        {
            
            add_delay( players[i] ); 
        }
        client_print_color( 0 , 0,"^4Round ^1Reached ^4... ^3Switching Team Now . " );
    }
}

public restartnumber( id, level, cid )
{
    if( !cmd_access( id, level, cid, 1 ) )
        return PLUGIN_HANDLED;
    
    roundnumber = 0;
    return PLUGIN_HANDLED;
}

public restart( id )
{
    roundnumber = 0;
    return PLUGIN_HANDLED;
}

public changeTeam( id )
{
    switch( cs_get_user_team( id ) )
    {
        case CS_TEAM_CT: cs_set_user_team( id, CS_TEAM_T );
        
        case CS_TEAM_T: cs_set_user_team( id, CS_TEAM_CT );
    }

    roundnumber = 0;
}

add_delay( id )
{
    switch( id )
    {
        case 1..7: set_task( 0.1, "changeTeam", id );
        case 8..15: set_task( 0.2, "changeTeam", id );
        case 16..23: set_task( 0.3, "changeTeam", id );
        case 24..32: set_task( 0.4, "changeTeam", id );
    }
}
Godofwar is offline
Nutu_
AlliedModders Donor
Join Date: Mar 2016
Location: Germany
Old 10-28-2018 , 07:51   Re: Switch Teams Add color message pls
Reply With Quote #7

put amx_atsrounds 25 in amxx.cfg
__________________
a simple act of caring creates an endless ripple.
Nutu_ is offline
Mr Misw
Member
Join Date: Aug 2018
Location: India
Old 10-28-2018 , 07:52   Re: Switch Teams Add color message pls
Reply With Quote #8

Nope I tested ...Its Working Fine In AMXX 1.8.3 5194
ScreenShot
__________________
Facebook ==> Here
ScrewedUP's Website :
Main Website
My Ranking System [Skin Version] :
ScrewedUP Ranking System
My Ranking System [Without Skin Version] :
ScrewedUP Ranking System

Last edited by Mr Misw; 10-28-2018 at 07:52.
Mr Misw is offline
Reply



Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT -4. The time now is 16:36.


Powered by vBulletin®
Copyright ©2000 - 2024, vBulletin Solutions, Inc.
Theme made by Freecode