Raised This Month: $12 Target: $400
 3% 

how get count of players


Post New Thread Reply   
 
Thread Tools Display Modes
Author Message
alonelive
Senior Member
Join Date: Jan 2011
Location: Big snow country.. :)
Old 10-03-2011 , 09:28   how get count of players
Reply With Quote #1

how i can get count of all players in the TEAMS (T and CT, not SPEC) on every round-end?

PHP Code:
public plugin_init() {
    
register_plugin(PLUGINVERSIONAUTHOR)
    
register_logevent("round_end"2"1=Round_End");
    
// Add your code here...
}

public 
round_end() {
    
    new 
get_playersnum()
    

__________________
sorry my bad english...
alonelive is offline
MyPc
Senior Member
Join Date: Sep 2011
Old 10-03-2011 , 09:34   Re: how get count of players
Reply With Quote #2

PHP Code:
#include <amxmodx>

public plugin_init()
{
    
register_logevent("round_end"2"1=Round_End");
}

public 
round_end()
{
    
    new 
players32 ], players_count
    
new terror_count 0ct_count 0
    get_players
playersplayers_count )
    for( new 
iplayers_counti++ )
    {
        switch( 
get_user_team) )
        {
            case 
1:
            {
                
terror_count++
            }
            case 
2:
            {
                
ct_count++
            }
        }
    }
    

MyPc is offline
Stereo
Veteran Member
Join Date: Dec 2010
Old 10-03-2011 , 10:04   Re: how get count of players
Reply With Quote #3

You can use:

PHP Code:
#define MAX_PLAYERS 32
new iPlayers[MAX_PLAYERS], iNumid
get_players
(iPlayersiNum"""CT"
or

PHP Code:
#define MAX_PLAYERS 32
new iPlayers[MAX_PLAYERS], iNumid
get_players
(iPlayersiNum"""TERRORIST"
Stereo is offline
alonelive
Senior Member
Join Date: Jan 2011
Location: Big snow country.. :)
Old 10-03-2011 , 10:58   Re: how get count of players
Reply With Quote #4

Big thanx, товарищи!
__________________
sorry my bad english...
alonelive is offline
Napoleon_be
Veteran Member
Join Date: Jul 2011
Location: Belgium
Old 10-03-2011 , 11:19   Re: how get count of players
Reply With Quote #5

or
PHP Code:
new iPlayers[32], iNumid
get_players
(iPlayersiNum"""TERRORIST"
__________________
Napoleon_be is offline
Send a message via Skype™ to Napoleon_be
Bugsy
AMX Mod X Moderator
Join Date: Feb 2005
Location: NJ, USA
Old 10-03-2011 , 11:33   Re: how get count of players
Reply With Quote #6

http://www.amxmodx.org/funcwiki.php?go=func&id=174

Use flag "e", not "", when passing team.
__________________
Bugsy is offline
ConnorMcLeod
Veteran Member
Join Date: Jul 2006
Location: France (95)
Old 10-03-2011 , 12:14   Re: how get count of players
Reply With Quote #7

get_players can return false results with dead players and flags "e", so considering you gonna execute this at round end, it would be better to prevent those false results.

PHP Code:
public round_end()
{
    new 
iTerroristsNumiCtsNum
    CountTeams
(iTerroristsNumiCtsNum)
}


CountTeams(&TERRORISTS, &CTS)
{
    
TERORISTS 0
    CTS 
0
    
new iPlayers[32], iNum
    get_players
(iPlayersiNum"h")
    if( !
iNum )
    {
        return
    }
    for(--
iNumiNum<=0iNum--)
    {
        switch( 
cs_get_user_team(iPlayers[iNum]) )
        {
            case 
CS_TEAM_T:++TERRORISTS
            
case CS_TEAM_CT:++CTS
        
}
    }

__________________
- tired and retired -

- my plugins -

Last edited by ConnorMcLeod; 10-04-2011 at 00:26.
ConnorMcLeod is offline
alonelive
Senior Member
Join Date: Jan 2011
Location: Big snow country.. :)
Old 10-03-2011 , 17:00   Re: how get count of players
Reply With Quote #8

Thanx to all!
__________________
sorry my bad english...
alonelive is offline
^SmileY
Veteran Member
Join Date: Jan 2010
Location: Brazil [<o>]
Old 10-03-2011 , 17:29   Re: how get count of players
Reply With Quote #9

Dont forgot to use #include <cstrike>

__________________
Projects:

- See my Git Hub: https://github.com/SmileYzn
PHP Code:
set_pcvar_num(pCvar, !get_pcvar_num(pCvar)); 
^SmileY is offline
Send a message via MSN to ^SmileY Send a message via Skype™ to ^SmileY
Doc-Holiday
AlliedModders Donor
Join Date: Jul 2007
Old 10-03-2011 , 23:30   Re: how get count of players
Reply With Quote #10

Quote:
Originally Posted by ConnorMcLeod View Post
get_players can return false results with dead players and flags "e", so considering you gonna execute this at round end, it would be better to prevent those false results.

PHP Code:
public round_end()
{
    new 
iTerroristsNumiCtsNum
    CountTeams
(iTerroristsNumiCtsNum)
}


CountTeams(&TERRORISTS, &CTS)
{
    
TERORISTS 0
    CTS 
0
    
new iPlayers[32], iNum
    get_players
(iPlayersiNum"h")
    if( !
iNum )
    {
        return
    }
    for(--
iNumiNum<0iNum--)
    {
        switch( 
cs_get_user_team(iPlayers[i]) )
        {
            case 
CS_TEAM_T:++TERRORISTS
            
case CS_TEAM_CT:++CTS
        
}
    }

Just to point out the obv i have to get you every once in a while...

Where is "i" defined?

iPlayers[i] -> iPlayers[iNum] ??
Doc-Holiday is offline
Reply


Thread Tools
Display Modes

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


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