OK I have this.
In plugin init.
PHP Code:
new g_maxplayers
new p_On
new bool:g_bSwitch[ 33 ]
PHP Code:
register_message(get_user_msgid("TeamInfo"), "message_teaminfo")
p_On = register_cvar( "amx_stbk", "1" ) // 1 = switching teams.
g_maxplayers = get_maxplayers()
register_event( "HLTV", "ev_newRound", "a", "1=0", "2=0" )
register_event( "DeathMsg", "ev_Death", "a" )
register_message( get_user_msgid( "TeamInfo" ), "msg_TeamInfo" )
///Here is the in the ct team can be max 4 ct's///
public message_teaminfo(msg_id, msg_dest){
if (msg_dest != MSG_ALL && msg_dest != MSG_BROADCAST) return;
new id = get_msg_arg_int(1)
static team[2]
get_msg_arg_string(2, team, sizeof team - 1)
if(team[0] == 'U' || team[0] == 'S') return;
new cts = ckrun_get_ct_num()
if(cts >= 4){
cs_set_user_team(id, CS_TEAM_T, CS_DONTCHANGE)
set_msg_arg_string(2, "TERRORIST")
}
}stock ckrun_get_ct_num(){
new num = 0 , i
for (i = 1; i <= g_maxplayers; i++){
if (is_user_connected(i) && get_user_team(i) == 2)
num ++
}
return num
}
///Switching teams, If terrorist killed ct switch their teams///
public client_disconnect(id)
{
g_bSwitch[ id ] = false
}
public ev_Death()
{
if( !get_pcvar_num( p_On ) )
{
return PLUGIN_CONTINUE;
}
static iAtt ; iAtt = read_data( 1 );
if( !( 1 <= iAtt <= g_maxplayers ) )
{
return PLUGIN_CONTINUE;
}
static iVic ; iVic = read_data( 2 );
if( !( 1 <= iVic <= g_maxplayers ) )
{
return PLUGIN_CONTINUE;
}
if( cs_get_user_team( iAtt ) == CS_TEAM_T && cs_get_user_team( iVic ) == CS_TEAM_CT )
{
if( !g_bSwitch[ iAtt ] )
{
g_bSwitch[ iAtt ] = true;
if( !g_bSwitch[ iVic ] )
{
g_bSwitch[ iVic ] = true;
}
}
}
return PLUGIN_CONTINUE;
}
public msg_TeamInfo( mid, Dest, id )
{
if( Dest != MSG_ALL && Dest != MSG_BROADCAST )
{
return PLUGIN_CONTINUE;
}
if( !get_pcvar_num( p_On ) )
{
return PLUGIN_CONTINUE;
}
if( g_bSwitch[ id ] )
{
g_bSwitch[ id ] = false;
}
return PLUGIN_CONTINUE;
}
public ev_newRound()
{
if( !get_pcvar_num( p_On ) )
{
return;
}
static i, CsTeams:team;
for( i = 1 ; i <= g_maxplayers ; i++ )
{
if( !is_user_connected( i ) || !g_bSwitch[ i ]
|| !( CS_TEAM_UNASSIGNED < ( team = cs_get_user_team( i ) ) < CS_TEAM_SPECTATOR ) )
continue;
cs_set_user_team( i, ( team % CS_TEAM_CT ) + CS_TEAM_T );
g_bSwitch[ i ] = false;
}
}
This is good if I'm using 2 Team info?
And this codes together worst working,maybe someone can configure it?