AlliedModders

AlliedModders (https://forums.alliedmods.net/index.php)
-   Scripting Help (https://forums.alliedmods.net/forumdisplay.php?f=11)
-   -   getting players, not working. (https://forums.alliedmods.net/showthread.php?t=221287)

devWaleed 07-20-2013 07:31

getting players, not working.
 
I don't know why this isn't working.

PHP Code:

get_players playersnum 
    for (new 
0i<numi++){
        
tempid    players[i]
        if(
cs_get_user_team(tempid) == CS_TEAM_T && is_user_alive(tempid)) t_count++;
        if(
cs_get_user_team(tempid) == CS_TEAM_CT && is_user_alive(tempid)) ct_count++;
    } 

It should get all team players for CT including bots, It firstly shows correct CT count, I have put it in /show event. So when I retype /show it doubles the CT count, for another /show. It doubles again and so on.

Why doesn't it work? I have tried it with live players too.

YamiKaitou 07-20-2013 07:49

Re: getting players, not working.
 
Are you resetting the value of ct_count and t_count before this loop?

ConnorMcLeod 07-20-2013 07:56

Re: getting players, not working.
 
yami is right, either those variables are static either they are global and you forget to reset them.

Anyway, would be more efficient to do :

PHP Code:

    get_players playerst_count"ae""TERRORIST" )
    
get_players playersct_count"ae""CT" 

You would have results in 2 lines, and you don't need to ever reset vars.
If you need to use players indexes for something else, then create 2 arrays, like players_t[32], players_ct[32].

devWaleed 07-20-2013 08:19

Re: getting players, not working.
 
so num is the number of players?

K1d0x 07-20-2013 08:47

Re: getting players, not working.
 
Quote:

Originally Posted by devWaleed (Post 1994990)
so num is the number of players?

Yes

PHP Code:

    new Players[32], iNumi;
    
    if(
cs_get_user_team(id) == CS_TEAM_T) {
        
get_players(PlayersiNum"ae""TERRORIST");
        
        for(
0iNumi++) {
            
id Players[i];
            
            
/* id = index of players from T Team and iNum = number of players from T */
        
}
    } 
    
    if(
cs_get_user_team(id) == CS_TEAM_CT) {
        
get_players(PlayersiNum"ae""CT");
        
        for(
0iNumi++) {
            
id Players[i];
            
            
/* id = index of players from CT Team and iNum = number of players from CT */
        
}
    } 



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

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