This site is a testing version, but all data is shared with the live forum.


Raised This Month: $ Target: $400
 0% 

getting players, not working.


Post New Thread Reply   
 
Thread Tools Display Modes
Author Message
devWaleed
Member
Join Date: Apr 2013
Location: Karachi, Pakistan
Old 07-20-2013 , 07:31   getting players, not working.
Reply With Quote #1

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.

Last edited by devWaleed; 07-20-2013 at 07:34. Reason: Sorry, provided wrong code.
devWaleed is offline
Send a message via Skype™ to devWaleed
YamiKaitou
Has a lovely bunch of coconuts
Join Date: Apr 2006
Location: Texas
Old 07-20-2013 , 07:49   Re: getting players, not working.
Reply With Quote #2

Are you resetting the value of ct_count and t_count before this loop?
__________________
ProjectYami Laboratories

I do not browse the forums regularly anymore. If you need me for anything (asking questions or anything else), then PM me (be descriptive in your PM, message containing only a link to a thread will be ignored).
YamiKaitou is offline
ConnorMcLeod
Veteran Member
Join Date: Jul 2006
Location: France (95)
Old 07-20-2013 , 07:56   Re: getting players, not working.
Reply With Quote #3

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].
__________________
- tired and retired -

- my plugins -
ConnorMcLeod is offline
devWaleed
Member
Join Date: Apr 2013
Location: Karachi, Pakistan
Old 07-20-2013 , 08:19   Re: getting players, not working.
Reply With Quote #4

so num is the number of players?
devWaleed is offline
Send a message via Skype™ to devWaleed
K1d0x
Senior Member
Join Date: Apr 2012
Location: Copenhagen, Denmark
Old 07-20-2013 , 08:47   Re: getting players, not working.
Reply With Quote #5

Quote:
Originally Posted by devWaleed View Post
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 */
        
}
    } 
__________________
I Hate people who can hate me !
K1d0x is offline
Send a message via Yahoo to K1d0x Send a message via Skype™ to K1d0x
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 14:32.


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