For readable code, above post is good example.
This example is just... with
trick.
PHP Code:
public void OnPluginStart()
{
HookEvent("player_death", player_death);
}
public void player_death(Event event, const char[] name, bool dontBroadcast)
{
int lastT = -1;
int CTcount = 0;
int team;
for(int i = 1; i <= MaxClients; i++)
{
if(!IsClientInGame(i))
continue;
team = GetClientTeam(i);
if(team < 2 || !IsPlayerAlive(i))
continue;
if(team == 2)
{
if(lastT == -1)
{
// We store player index in variable, first time.
lastT = i;
}
else
{
// When there are more than one T alive in team, this variable will get reset (-2)
lastT = -2;
}
}
else
{
CTcount++;
}
}
if(lastT > 0 && CTcount > 1)
{
ServerCommand("sm_beacon #%i", GetClientUserId(lastT));
}
}
__________________