How can I find out the # of players on a team?
This is probably a very simple question; but i'm new so give me a break. What can I use to find out how many players are on a team?
|
Re: How can I find out the # of players on a team?
new players[32],num,teamnum=0;
get_players(players,num,"ce","team"); for(new i=0;i<num;i++) teamnum++; /*flags: "a" - Don't return dead players "b" - Don't return alive players "c" - Skip bots "d" - Skip real players "e" - Match with passed team "f" - Match with part of name "g" - Ignore case sensitivity "h" - Skip HLTV */ |
Re: How can I find out the # of players on a team?
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() Code:
public jointeam() |
Re: How can I find out the # of players on a team?
As a side note, get_players() and is kind of buggy when parsing out teams. It doesn't look like you should have any problems, but beware :O....
|
Re: How can I find out the # of players on a team?
Quote:
How can I resolve this issue so that the code executes whenever a player joins a team, even if they weren't on one previously? |
Re: How can I find out the # of players on a team?
It does execute the code within the loop. But your code does not do anything because it does not fall within the paramters of your if statements.
get_user_team(x) will not work on the player that just executed the command to join the team. Think of the sequence of it: 1-Player joins server, with "no team assigned yet." 2-Player executes the "jointeam" command. 3-AMXX interrupts the command and executes code. 4-Player is then assigned to the team he joined. Theoretically, you could block the person from joining the team, which is why AMXX interrupts and comes before, not after in this case. So anyway, Instead of doing a get_user_team() on the player joining the team, you should instead read the argument of the command being executed. Code:
In the above code block, the integer variable new_team will be equal to the team the client tried to join. Like I said, get_user_team() won't return anything for that client yet as the team has yet to be set. |
Re: How can I find out the # of players on a team?
Quote:
Quote:
|
Re: How can I find out the # of players on a team?
Code:
This basically does the stuffs for the player doing the command, and then does it in addition for everyone else. This just an example and obviously not the most efficient way. But this way you get the idea. |
Re: How can I find out the # of players on a team?
OH, I see now. Thanks! I'm still learning, so most efficient way or not, if it works and I learned a new way do so something, it's successfully. :up: Thanks for the help, I'll try the code out when I get home later today and see what happens.
|
| All times are GMT -4. The time now is 16:08. |
Powered by vBulletin®
Copyright ©2000 - 2024, vBulletin Solutions, Inc.