AlliedModders

AlliedModders (https://forums.alliedmods.net/index.php)
-   Scripting Help (https://forums.alliedmods.net/forumdisplay.php?f=11)
-   -   how get count of players (https://forums.alliedmods.net/showthread.php?t=168739)

alonelive 10-03-2011 09:28

how get count of players
 
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()
    



MyPc 10-03-2011 09:34

Re: how get count of players
 
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++
            }
        }
    }
    



Stereo 10-03-2011 10:04

Re: how get count of players
 
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"


alonelive 10-03-2011 10:58

Re: how get count of players
 
Big thanx, товарищи! :)

Napoleon_be 10-03-2011 11:19

Re: how get count of players
 
or
PHP Code:

new iPlayers[32], iNumid
get_players
(iPlayersiNum"""TERRORIST"


Bugsy 10-03-2011 11:33

Re: how get count of players
 
http://www.amxmodx.org/funcwiki.php?go=func&id=174

Use flag "e", not "", when passing team.

ConnorMcLeod 10-03-2011 12:14

Re: how get count of players
 
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
        
}
    }



alonelive 10-03-2011 17:00

Re: how get count of players
 
Thanx to all!

^SmileY 10-03-2011 17:29

Re: how get count of players
 
Dont forgot to use #include <cstrike>

:P

Doc-Holiday 10-03-2011 23:30

Re: how get count of players
 
Quote:

Originally Posted by ConnorMcLeod (Post 1567710)
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] ??


All times are GMT -4. The time now is 06:19.

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