Raised This Month: $ Target: $400
 0% 

How can I find out the # of players on a team?


  
 
 
Thread Tools Display Modes
Prev Previous Post   Next Post Next
I3lade203
Junior Member
Join Date: Jun 2007
Old 09-18-2007 , 16:34   Re: How can I find out the # of players on a team?
Reply With Quote #3

Thanks, I figured I was going to have to use a for loop but I wasn't sure if there was already a pre-defined function that would just retrieve the number or not. Guess not, but I do have a question...

Here's what my code looks like so far:

Code:
public plugin_init() 
{
    register_plugin(PLUGIN, VERSION, AUTHOR)    
    register_menucmd(register_menuid("Team_Select"), MENU_KEY_1 | MENU_KEY_2, "jointeam")    
    register_clcmd("jointeam 1", "jointeam") 
    register_clcmd("jointeam 2", "jointeam") 
    register_clcmd("jointeam 5", "jointeam")
    
}
Code:
public jointeam()
{
    new red_players, blue_players, x, numplayers
    numplayers = get_playersnum()
    
    for(x=0; x<=32; x++)
    {
    
        
        
        if( get_user_team(x) == 2 )
        {
            blue_players = blue_players + 1
            set_cvar_num("cr_demoman", -1)
        
        }else if (get_user_team(x) == 1 )
        {
            red_players = red_players +1
            set_cvar_num("cr_sniper", -1)
        }
    
    }
    
  
    
    
}
Thanks to you, I was able to get the number of players per team working. HOWEVER, the problem i'm now having is that the above code only exectues when a player CHANGES teams, rather then joins teams. So, if I join a server with the above code running, and I pick "Team 1" nothing will happen. If however after I spawn I join team 2, and then join team 1 again the "team 1" code will work. How can I fix this so that it'll execute the code whenever the player chooses the team, rather then switches to the team?

Last edited by I3lade203; 09-18-2007 at 18:46.
I3lade203 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 16:08.


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