Raised This Month: $ Target: $400
 0% 

get team players


  
 
 
Thread Tools Display Modes
Prev Previous Post   Next Post Next
Debesėlis
Senior Member
Join Date: Aug 2008
Location: Lithuania
Old 10-25-2013 , 10:05   Re: get team players
Reply With Quote #3

Quote:
Originally Posted by Firippu View Post
There are multiple ways of doing this.. One way, you could loop through all possible player IDs and count the ones under given conditions.

This example here stores player counts in variables for both teams.
PHP Code:
new iTEcount,iCTcount
for(new id=1id<=32id++) {
    if(
is_user_connected(id)) {
        switch(
cs_get_user_team(id)) {
            case 
CS_TEAM_T: {
                
iTEcount++
            } case 
CS_TEAM_CT: {
                
iCTcount++
            }
        }
    }
}

// iTEcount = number of players in terrorist team
// iCTcount = number of players in counter terrorist team

// example
if(iTEcount>=5) {
    
// this will run if there are 5 or more players in terrorist team


Can i use it in client_putinserver ?
PHP Code:
public client_putinserver id )
{
    new 
iTEcountiCTcount;
    for( new 
id 1id <= 32id++ )
    {
        if ( 
is_user_connectedid ) )
        {
            switch ( 
cs_get_user_teamid ) )
            {
                case 
CS_TEAM_TiTEcount++
                case 
CS_TEAM_CTiCTcount++
            }
        }
    }
}
    
    if ( 
iTEcount >= && iCTcount >= )
    {
        if ( !
g_bIsFreezeTime && !is_user_botid ) && !is_user_hltvid ) )
            
// next stage
    
}

Debesėlis is offline
 



Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT -4. The time now is 23:22.


Powered by vBulletin®
Copyright ©2000 - 2024, vBulletin Solutions, Inc.
Theme made by Freecode