Code:
#include <amxmodx>
#include <amxmisc>
#include <fakemeta>
#define MAX_CTS 4
enum FmTeams
{
FM_TEAM_UNASSIGNED,
FM_TEAM_T,
FM_TEAM_CT,
FM_TEAM_SPECTATOR
};
new const g_TeamInfo[FmTeams][] =
{
"UNASSIGNED",
"TERRORIST",
"CT",
"SPECTATOR"
};
#define fm_get_user_team(%1) FmTeams:get_pdata_int(%1, 114)
new g_max_clients;
public plugin_init()
{
register_message(get_user_msgid("TeamInfo"), "MessageTeamInfo");
g_max_clients = get_maxplayers();
}
public MessageTeamInfo(msgid, dest, receiver)
{
if( dest != MSG_ALL && dest != MSG_BROADCAST ) return;
new teamname[3];
get_msg_arg_string(2, teamname, sizeof(teamname) - 1);
new FmTeams:team;
for( new FmTeams:i = FM_TEAM_UNASSIGNED; i < FmTeams; i++ )
{
if( g_TeamInfo[i][0] == teamname[0] )
{
team = i;
break;
}
}
new client = get_msg_arg_int(1);
if( team == FM_TEAM_CT && fm_get_user_team(client) == team )
{
new ctnum;
for( new i = 1; i <= g_max_clients; i++ )
{
if( i != client
&& is_user_connected(i)
&& fm_get_user_team(i) == FM_TEAM_CT
&& ++ctnum == MAX_CTS )
{
set_pdata_int(client, 114, _:FM_TEAM_T);
set_msg_arg_string(2, g_TeamInfo[FM_TEAM_T]);
break;
}
}
}
if( get_pcvar_num(p_On) )
{
g_bSwitch[client] = false;
}
}
__________________