Raised This Month: $ Target: $400
 0% 

Getting team number function with cstrike


  
 
 
Thread Tools Display Modes
Prev Previous Post   Next Post Next
ConnorMcLeod
Veteran Member
Join Date: Jul 2006
Location: France (95)
Old 07-26-2009 , 05:27   Re: Getting team number function with cstrike
Reply With Quote #4

Start id should be 1 and not 0, also, don't forfet to retrieve maxplayers value.

PHP Code:
enum {
    
All,
    
Alive,
    
Dead
}

fnGetTeamCount(CsTeams:TeamiType)
{
    new 
iCount 0
    
for(new id 1id <= g_iMaxPlayersid++)
    {
        switch( 
iType )
        {
            case 
All:
            {
                if( !
is_user_connected(id) )
                {
                    continue
                }
            }
            case 
Alive:
            {
                if( !
is_user_alive(id) )
                {
                    continue
                }
            }
            case 
Dead:
            {
                if(  !
is_user_connected(id) || is_user_alive(id) )
                {
                    continue
                }
            }
        }
        if( 
cs_get_user_team(id) == Team )
        {
            ++
iCount
        
}
    }

    return 
iCount


Also, if you only need alive players, you can use this passing team NAME :
PHP Code:
fnGetAliveTeamCount(const szTeam[])
{
    new 
iPlayers[32], iNum
    get_players
(iPlayersiNum"ae"szTeam)
    return 
iNum

__________________
- tired and retired -

- my plugins -

Last edited by ConnorMcLeod; 07-26-2009 at 13:10.
ConnorMcLeod 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 18:19.


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