Raised This Month: $ Target: $400
 0% 

check team player number


Post New Thread Reply   
 
Thread Tools Display Modes
Author Message
JeweL`
Member
Join Date: Oct 2009
Location: Turkey/Kocaeli
Old 07-21-2010 , 17:07   check team player number
Reply With Quote #1

sorry for my english..

i want to write this on server

%s player on terrorists team, %s player on counter terrorist team..

how i can check that numbers of team players. i didnt find it.
JeweL` is offline
Send a message via MSN to JeweL` Send a message via Skype™ to JeweL`
grimvh2
Veteran Member
Join Date: Nov 2007
Location: Fishdot Nation
Old 07-21-2010 , 17:34   Re: check team player number
Reply With Quote #2

PHP Code:

new players[32], tnumctnum
get_players
(players,ctnum,"e""CT")
get_players(players,tnum,"e""TERRORIST")

// then print tnum and ctnum, thats %i not %s 
__________________
I am out of order!

Last edited by grimvh2; 07-21-2010 at 17:52.
grimvh2 is offline
ot_207
Veteran Member
Join Date: Jan 2008
Location: Romania The Love Country
Old 07-21-2010 , 17:40   Re: check team player number
Reply With Quote #3

PHP Code:
#include <cstrike>
#include <amxmodx>

// plugin_init BLA BLA

public client_connect(id)
{
    new 
total get_maxplayers()
    new 
ts
    
new ct
    
    
for (new i=1;i<=total;i++)
    {
        if (
is_user_connected(i))
        {
            if (
cs_get_user_team(i) == CS_TEAM_T)
                
ts++
            if (
cs_get_user_team(i) == CS_TEAM_CT)
                
ct++
        }
    }
    
    
client_print(0print_chat"%d Tero %d CT"tsct)

Wrote it here. So try to be careful when testing it.
__________________
My approved plug-ins | Good for newbies! | Problems?

Back, will come around when I have time.
ot_207 is offline
grimvh2
Veteran Member
Join Date: Nov 2007
Location: Fishdot Nation
Old 07-21-2010 , 17:53   Re: check team player number
Reply With Quote #4

ot, can get wrong. U should add a bool and set it true when he connects and false when he disconnects and use that bool instead of is_user_connected().
Worked fine with me on my private projects.
__________________
I am out of order!
grimvh2 is offline
drekes
Veteran Member
Join Date: Jul 2009
Location: Vault 11
Old 07-21-2010 , 18:33   Re: check team player number
Reply With Quote #5

I would use something like this:
PHP Code:
stock get_terro_amount()
{
    new 
players[32], pnumtempidamount;
    
get_players(playerspnum);
    
    for(new 
0pnumi++)
    {
        
tempid players[i];
        
        if(
is_user_connected(tempid))
        {
            if(
get_user_team(tempid) == 1)
                
amount++;
        }
    }
    
    return 
amount;
}

stock get_ct_amount()
{
    new 
players[32], pnumtempidamount;
    
get_players(playerspnum);
    
    for(new 
0pnumi++)
    {
        
tempid players[i];
        
        if(
is_user_connected(tempid))
        {
            if(
get_user_team(tempid) == 2)
                
amount++;
        }
    }
    
    return 
amount;

__________________

Quote:
Originally Posted by nikhilgupta345 View Post
You're retarded.
drekes is offline
Send a message via MSN to drekes
Bugsy
AMX Mod X Moderator
Join Date: Feb 2005
Location: NJ, USA
Old 07-21-2010 , 19:27   Re: check team player number
Reply With Quote #6

untested
PHP Code:
//Usage
new iTs iCTs;
GetTeamCountsiTs iCTs );
client_printprint_chat "Terrorist=%d CT=%d" iTs iCTs );

public 
GetTeamCounts( &TCount , &CTCount )
{
    new 
iMaxPlayers get_maxplayers();
    
TCount 0;
    
CTCount 0;

    for ( new 
<= iMaxPlayers i++ )
    {
        if ( !
is_user_connected) )
            continue;

        switch ( 
cs_get_user_team) )
        {
            case 
CS_TEAM_TTCount++;
            case 
CS_TEAM_CTCTCount++;
        }
    }

__________________

Last edited by Bugsy; 07-21-2010 at 19:45.
Bugsy is offline
fysiks
Veteran Member
Join Date: Sep 2007
Location: Flatland, USA
Old 07-21-2010 , 21:08   Re: check team player number
Reply With Quote #7

@drekes, if you use get_players() you don't need to check if they are connected. get_players() won't return non-connected players.
__________________
fysiks is offline
Kreation
Veteran Member
Join Date: Jan 2010
Location: Illinois
Old 07-21-2010 , 21:12   Re: check team player number
Reply With Quote #8

Quote:
Originally Posted by fysiks View Post
@drekes, if you use get_players() you don't need to check if they are connected. get_players() won't return non-connected players.
Really? Never knew that, I think I got a run time error before from that. Guess not, I'll remove that from my stock.
__________________
Hi.
Kreation is offline
fysiks
Veteran Member
Join Date: Sep 2007
Location: Flatland, USA
Old 07-21-2010 , 21:19   Re: check team player number
Reply With Quote #9

Quote:
Originally Posted by Kreation View Post
Really? Never knew that, I think I got a run time error before from that. Guess not, I'll remove that from my stock.
If it returned non-connected players then get_players() would look like:

Code:
stock get_players(players[], &num)
{
    players[0] = 1
    players[1] = 2
    // ...
    players[31] = 32
    num = 32
}
Correct me if you feel that I am wrong.
__________________
fysiks is offline
K.K.Lv
Veteran Member
Join Date: Aug 2008
Location: GameFolder
Old 07-21-2010 , 21:41   Re: check team player number
Reply With Quote #10

PHP Code:
stock get_team_playernum(iTeam) {
    static 
players[32], num
    
static iNum
    get_players
(playersnum)
    for (new 
0numi++) {
        if (
get_user_team(players[i]) == iTeam) {
            
iNum++
        }
    }
    return 
iNum

un-test.

Quote:
should add a bool and set it true when he connects and false when he disconnects
you can do it like the following code, then, I think you needn't to check when player disconnect.
should work:
PHP Code:
 
const BOOL_ARRAY[33] = {false,...}
 
new 
bool:g_bvar[33]
 
public 
client_connect(id) {
    
g_bvar BOOL_ARRAY
    g_bvar
[id] = true

__________________
QQ:116268742

Last edited by K.K.Lv; 07-21-2010 at 21:52.
K.K.Lv is offline
Send a message via MSN to K.K.Lv
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 07:07.


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