Help me understand this not balanced count.
What this code does is that if some of the team has 2 teamates only it runs a command.
But i want to change it to 4 teamates so i changed all 2 numbers to 4 but it doesnt work.
Instead it says something wierd or nothing at all. Like -5 teamates.
So whats the mathematics of this code how does it count!?
How to make so it counts 4 teamates or less.
PHP Code:
if ( !g_CustomGame || true )
{
if (g_IsStarted)
{
new numT, numCt;
for ( new i = 1 ; i <= gMaxPlayers ; i++ )
{
if ( is_user_connected(i) )
{
if ( cs_get_user_team(i) == CS_TEAM_T )
numT++
else if ( cs_get_user_team(i) == CS_TEAM_CT )
numCt++
}
}
if ( numT <= (get_pcvar_num(cvar_pLeft)/2) - 2 || numCt <= (get_pcvar_num(cvar_pLeft)/2) - 2 )
{
if ( g_NotBalanced == 2 )
{
if (numT > numCt)
client_print(0, print_chat, "%s %L", PREFIX, LANG_PLAYER, "T_AUTO_WON")
else if (numCt > numT)
client_print(0, print_chat, "%s %L", PREFIX, LANG_PLAYER, "CT_AUTO_WON")
else if (numCt == numT)
client_print(0, print_chat, "%s %L", PREFIX, LANG_PLAYER, "NO_TEAM_WON")
client_print(0, print_chat, "%s %L", PREFIX, LANG_PLAYER, "ENDING_MATCH")
new taskId = scanForTaskID()
set_task(5.0, "EndMatch", taskId)
g_NotBalanced = 0
}
else
{
client_print(0, print_chat, "%s %L", PREFIX, LANG_PLAYER, "NOT_ENOUGH_TEAMMATES", (get_pcvar_num(cvar_pLeft)/2) - 2)
client_print(0, print_chat, "%s %L", PREFIX, LANG_PLAYER, "NOT_ENOUGH_TEAMMATES2", 2 - g_NotBalanced )
g_NotBalanced++
}
}
else
g_NotBalanced = 0;
}
}
return PLUGIN_HANDLED