PHP Code:
public Action CMD_Team(int client, int args)
{
if(!IsClientValid(client) || !IsClientInGame(client))
{
return Plugin_Handled;
}
if((args != 2) && (args != 3))
{
ReplyToCommand(client, "%t", "CMD_Team_Usage");
return Plugin_Handled;
}
char target_name[MAX_TARGET_LENGTH], buffer[512];
int target_list[MAXPLAYERS], target_count;
bool tn_is_ml;
GetCmdArg(1, buffer, sizeof(buffer));
if((target_count = ProcessTargetString(buffer, client, target_list, MAXPLAYERS, COMMAND_FILTER_CONNECTED, target_name, sizeof(target_name), tn_is_ml)) <= 0)
{
ReplyToTargetError(client, target_count);
return Plugin_Handled;
}
int team;
GetCmdArg(2, buffer, sizeof(buffer));
if(StrEqual(buffer, "spectator", false) || StrEqual(buffer, "spec", false) || StrEqual(buffer, "1", false))
{
team = CS_TEAM_SPECTATOR;
if(tn_is_ml)
{
ShowActivity2(client, CMD_PREFIX, "%t", "CMD_Team_Spec", target_name);
LogActionEx(client, "%t", "CMD_Team_Spec", target_name);
}
else
{
ShowActivity2(client, CMD_PREFIX, "%t", "CMD_Team_Spec", "_s", target_name);
LogActionEx(client, "%t", "CMD_Team_Spec", "_s", target_name);
}
}
else if(StrEqual(buffer, "t", false) || StrEqual(buffer, "2", false))
{
team = CS_TEAM_T;
if(tn_is_ml)
{
ShowActivity2(client, CMD_PREFIX, "%t", "CMD_Team_T", target_name);
LogActionEx(client, "%t", "CMD_Team_T", target_name);
}
else
{
ShowActivity2(client, CMD_PREFIX, "%t", "CMD_Team_T", "_s", target_name);
LogActionEx(client, "%t", "CMD_Team_T", "_s", target_name);
}
}
else if(StrEqual(buffer, "ct", false) || StrEqual(buffer, "3", false))
{
team = CS_TEAM_CT;
if(tn_is_ml)
{
ShowActivity2(client, CMD_PREFIX, "%t", "CMD_Team_CT", target_name);
LogActionEx(client, "%t", "CMD_Team_CT", target_name);
}
else
{
ShowActivity2(client, CMD_PREFIX, "%t", "CMD_Team_CT", "_s", target_name);
LogActionEx(client, "%t", "CMD_Team_CT", "_s", target_name);
}
}
else
{
ReplyToCommand(client, "%t", "CMD_Invalid_Team");
return Plugin_Handled;
}
GetCmdArg(3, buffer, sizeof(buffer));
int value = StringToInt(buffer);
for(int i = 0; i < target_count; i++)
{
if(IsClientInGame(target_list[i]))
{
if(value == 1)
{
if(team != 1)
{
CS_SwitchTeam(target_list[i], team);
if(IsPlayerAlive(target_list[i]))
{
CS_RespawnPlayer(target_list[i]);
}
}
else
{
ChangeClientTeam(target_list[i], team);
}
}
else
{
SetEntProp(target_list[i], Prop_Data, "m_iPendingTeamNum", team);
}
}
}
return Plugin_Handled;
}