View Single Post
Bacardi
Veteran Member
Join Date: Jan 2010
Location: mom's basement
Old 08-10-2022 , 05:40   Re: [CS:GO] How to get team count ? CT/T
Reply With Quote #3

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[] namebool dontBroadcast)
{
    
int lastT = -1;
    
int CTcount 0;
    
int team;

    for(
int i 1<= MaxClientsi++)
    {
        if(!
IsClientInGame(i))
            continue;
        
        
team GetClientTeam(i);
        
        if(
team || !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 && CTcount 1)
    {
        
ServerCommand("sm_beacon #%i"GetClientUserId(lastT));
    }

__________________
Do not Private Message @me
Bacardi is offline