AlliedModders

AlliedModders (https://forums.alliedmods.net/index.php)
-   Scripting Help (https://forums.alliedmods.net/forumdisplay.php?f=11)
-   -   Best way count players (https://forums.alliedmods.net/showthread.php?t=317787)

pentakill 07-29-2019 23:03

Best way count players
 
Is this the best way to count players?
PHP Code:

new ctsnumtsnumteam

    
for (new i=1i<=MAX_JOGADORESi++)
    {
        if (!
is_user_connected(i) || !is_user_alive(i)) continue
        
team get_user_team(i)
        if (
team == 1tsnum++
        else if (
team == 2ctsnum++
    } 


Bugsy 07-29-2019 23:07

Re: Best way count players
 
May be easiest to use get_players with the team flag. To do it manually I'd do this:
PHP Code:

new iTeamCountsCsTeams ];

for (new 
i=1i<=MAX_JOGADORESi++) 

    if ( 
is_user_alive) ) 
    {
        
iTeamCountscs_get_user_team) ]++;
    }
}  

//iTeamCounts[ CS_TEAM_T ] = T count
//iTeamCounts[ CS_TEAM_CT ] = CT count 



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

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