Raised This Month: $ Target: $400
 0% 

How to get team count?


Post New Thread Reply   
 
Thread Tools Display Modes
Author Message
tRipLe.
Senior Member
Join Date: Dec 2009
Location: Estonia, Pärnu
Old 03-11-2011 , 14:35   How to get team count?
Reply With Quote #1

I'm having a problem with a plugin, i know what i have to do to solve it. I need to check if terrorist team size is bigger than 0 or not. If yes then do the action or else do nothing.

I don't know how to get terrorist team size , but i think it has to be quite simple, please help!

Thanks.
__________________
τsэ - servers.ee:9987
tRipLe. is offline
Send a message via MSN to tRipLe. Send a message via Skype™ to tRipLe.
Emp`
AMX Mod X Plugin Approver
Join Date: Aug 2005
Location: Decapod 10
Old 03-11-2011 , 14:44   Re: How to get team count?
Reply With Quote #2

Pseudo code:
Code:
loop through players
     if player is on terrorist team
          increase variable by 1
Emp` is offline
Send a message via AIM to Emp` Send a message via MSN to Emp` Send a message via Yahoo to Emp` Send a message via Skype™ to Emp`
tRipLe.
Senior Member
Join Date: Dec 2009
Location: Estonia, Pärnu
Old 03-11-2011 , 14:55   Re: How to get team count?
Reply With Quote #3

PHP Code:
new countnumplayers[32]
get_players(players,num)
for(new 
i=0;i<num;i++) {
        new 
plrplr=players[i]
        if(
cs_get_user_team(plr)==CS_TEAM_T&&is_user_connected(plr)) {
              
count++
        }
        if(
count>0) {
               return 
PLUGIN_HANDLED
        
} else {
               
// do my action, because there are no terrorists
        
}

Like this? Sry, im not very experienced .

E: actually if i look at this i don't understand at all
__________________
τsэ - servers.ee:9987
tRipLe. is offline
Send a message via MSN to tRipLe. Send a message via Skype™ to tRipLe.
drekes
Veteran Member
Join Date: Jul 2009
Location: Vault 11
Old 03-11-2011 , 15:29   Re: How to get team count?
Reply With Quote #4

PHP Code:
new countnumplayers[32], tempid;
get_players(playersnum);

for(new 
0numi++)
{
    
tempid players[i];

    if(
cs_get_user_team(tempid) == CS_TEAM_T)
        
count++;
}

// Count now equals the amount of connected terrorist players. 
__________________

Quote:
Originally Posted by nikhilgupta345 View Post
You're retarded.

Last edited by drekes; 03-11-2011 at 17:18.
drekes is offline
Send a message via MSN to drekes
tRipLe.
Senior Member
Join Date: Dec 2009
Location: Estonia, Pärnu
Old 03-11-2011 , 15:52   Re: How to get team count?
Reply With Quote #5

Thanks.
__________________
τsэ - servers.ee:9987
tRipLe. is offline
Send a message via MSN to tRipLe. Send a message via Skype™ to tRipLe.
Emp`
AMX Mod X Plugin Approver
Join Date: Aug 2005
Location: Decapod 10
Old 03-11-2011 , 16:16   Re: How to get team count?
Reply With Quote #6

Quote:
Originally Posted by drekes View Post
PHP Code:
new countnumplayers[32];
get_players(playersnum);

for(new 
0numi++)
{
    if(
cs_get_user_team(id) == CS_TEAM_T)
        
count++;
}

// Count now equals the amount of connected terrorist players. 
You might want to fix that.
Emp` is offline
Send a message via AIM to Emp` Send a message via MSN to Emp` Send a message via Yahoo to Emp` Send a message via Skype™ to Emp`
drekes
Veteran Member
Join Date: Jul 2009
Location: Vault 11
Old 03-11-2011 , 17:17   Re: How to get team count?
Reply With Quote #7

Quote:
Originally Posted by Emp` View Post
You might want to fix that.
Done, can't believe i missed that
__________________

Quote:
Originally Posted by nikhilgupta345 View Post
You're retarded.
drekes is offline
Send a message via MSN to drekes
diablix
Senior Member
Join Date: Jan 2010
Location: Warsaw, Poland
Old 03-11-2011 , 18:28   Re: How to get team count?
Reply With Quote #8

Won't be easier to count with a team flag?
diablix is offline
Send a message via Skype™ to diablix
wrecked_
Veteran Member
Join Date: Jan 2010
Location: New York (GMT-5)
Old 03-11-2011 , 18:35   Re: How to get team count?
Reply With Quote #9

Quote:
Originally Posted by diablix View Post
Won't be easier to count with a team flag?
Using get_players() with the flag "e" is bugged unless also used with the flag "a". This is because when players swap teams while dead, TeamInfo isn't called until they are alive. Since the OP doesn't want to get only the number of players on each team that are alive, looping or caching team join is necessary.
__________________
[ Paid Requests ]
DO NOT PM ME ABOUT BLOCKMAKER
NO PRIVATE SUPPORT
wrecked_ is offline
fysiks
Veteran Member
Join Date: Sep 2007
Location: Flatland, USA
Old 03-11-2011 , 18:43   Re: How to get team count?
Reply With Quote #10

Quote:
Originally Posted by wrecked_ View Post
Using get_players() with the flag "e" is bugged unless also used with the flag "a". This is because when players swap teams while dead, TeamInfo isn't called until they are alive. Since the OP doesn't want to get only the number of players on each team that are alive, looping or caching team join is necessary.
I think Exolent submitted a fix for that but hasn't been pushed onto 1.8.2
__________________
fysiks is offline
Reply



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 14:29.


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