Hi I'm using Exolent's team ratio.
I add to the plugin a verification of user name, if contain that tag, change the user team.
PHP Code:
#include < amxmodx >
#include < amxmisc >
#include < cstrike >
#include < hamsandwich >
new pCvar_TerrPercent;
new pCvar_Advantage;
public plugin_init( )
{
register_plugin( "Team Ratio", "0.0.1", "Exolent" );
register_event( "HLTV", "EventNewRound", "a", "1=0", "2=0" );
register_event( "TextMsg", "EventRestartRound", "a", "2&#Game_C", "2&#Game_w" );
register_logevent( "EventRoundEnd", 2, "1=Round_End" );
pCvar_TerrPercent = register_cvar( "tr_terr_percent", "75" );
pCvar_Advantage = register_cvar( "tr_advantage", "1" );
set_task( 20.0, "TaskCheckTeams", 1234 );
}
public EventNewRound( )
{
set_task( 1.0, "TaskCheckTeams", 1234 );
}
public EventRestartRound( )
{
remove_task( 1234 );
}
public EventRoundEnd( )
{
remove_task( 1234 );
}
public TaskCheckTeams( )
{
new Float:fTerrPercent = get_pcvar_float( pCvar_TerrPercent );
if( fTerrPercent > 100.0 )
{
CheckTeams( 10000.0 / fTerrPercent, CS_TEAM_CT );
}
else
{
CheckTeams( fTerrPercent, CS_TEAM_T );
}
}
CheckTeams( Float:fPercent, CsTeams:iTeam )
{
new CsTeams:iOtherTeam = CsTeams:( ( _:iTeam % 2 ) + 1 );
new iPlayers[ 32 ], iNum;
get_players( iPlayers, iNum, "a" );
for( new i = 0; i < iNum; i++ )
{
switch( cs_get_user_team( iPlayers[ i ] ) )
{
case CS_TEAM_T:
{
}
case CS_TEAM_CT:
{
}
default:
{
iPlayers[ i-- ] = iPlayers[ --iNum ];
}
}
}
new CsTeams:iTeamAdvantage = CsTeams:get_pcvar_num( pCvar_Advantage );
new floatround_method:iRoundMethod;
if( iTeamAdvantage == iTeam )
{
iRoundMethod = floatround_ceil;
}
else if( iTeamAdvantage == iOtherTeam )
{
iRoundMethod = floatround_floor;
}
else
{
iRoundMethod = floatround_round;
}
new iReq = floatround( float( iNum ) * fPercent / 100.0, iRoundMethod );
new iReqOther = iNum - iReq;
for( new i = 0; i < iNum; i++ )
{
if( cs_get_user_team( iPlayers[ i ] ) == iTeam )
{
if( iReq > 0 )
{
iReq--;
iPlayers[ i-- ] = iPlayers[ --iNum ];
}
}
else
{
if( iReqOther > 0 )
{
iReqOther--;
iPlayers[ i-- ] = iPlayers[ --iNum ];
}
}
}
new iRandom, iPlayer;
for( new i = 0; i < iReq; i++ )
{
iRandom = random( iNum );
iPlayer = iPlayers[ iRandom ];
iPlayers[ iRandom ] = iPlayers[ --iNum ];
if( cs_get_user_team( iPlayer ) == iOtherTeam)
{
cs_set_user_team( iPlayer, iTeam );
ExecuteHamB( Ham_Spawn, iPlayer );
}
}
for( new i = 0; i < iReqOther; i++ )
{
iRandom = random( iNum );
iPlayer = iPlayers[ iRandom ];
iPlayers[ iRandom ] = iPlayers[ --iNum ];
if( check_user_name( iPlayer ) && cs_get_user_team( iPlayer ) == iTeam)
{
cs_set_user_team( iPlayer, iOtherTeam );
ExecuteHamB( Ham_Spawn, iPlayer );
}
}
}
stock check_user_name(id)
{
new name[32];
get_user_name(id, name, charsmax(name));
if (containi(name, "[TAG]") != -1)
return 1;
return 0;
}
The problem is when "check_user_name" return 0 the loop breaks and server doesn't pass any player.