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

asdasd


Post New Thread Reply   
 
Thread Tools Display Modes
Author Message
Kellan123
AlliedModders Donor
Join Date: Aug 2012
Old 03-20-2014 , 18:16   asdasd
Reply With Quote #1

Hey all, if join server then working Terrorits or Counter-Terrorits Team and then i transfered himself to Terrorist or Counter-Terrorits Team then not worked...

PHP Code:
Code Removed

Last edited by Kellan123; 03-26-2014 at 18:17. Reason: Lawl himself fixed neva didnt know it :(
Kellan123 is offline
Baws
Veteran Member
Join Date: Oct 2012
Old 03-20-2014 , 22:10   Re: GetPlayers Bugging
Reply With Quote #2

i don't really know if this will work but i tried at least.
PHP Code:
public GetPlayers()
{
    
//static terrorists, counter_terrorists
 
    
for(new id 1id <= get_maxplayers(); id++)
    {
        if(
is_user_connected(id) && is_user_alive(id))
        {
            if(
cs_get_user_team(id) == CS_TEAM_T)
            {
                
cs_set_user_team(id, (CS_TEAM_T terrorists++))
                
//terrorists++
            
}
 
            if(
cs_get_user_team(id) == CS_TEAM_CT)
            {
                
cs_set_user_team(id, (CS_TEAM_CT counter_terrorists++))
                
//counter_terrorists++
            
}
        }
    }

    if(
terrorists && counter_terrorists)
    {
        return 
PLUGIN_CONTINUE
    
}
 
    return 
PLUGIN_HANDLED

__________________
Like my clean plugins and work?
Baws is offline
Blizzard_87
Veteran Member
Join Date: Oct 2012
Old 03-20-2014 , 22:20   Re: GetPlayers Bugging
Reply With Quote #3

Quote:
Originally Posted by baws View Post
i don't really know if this will work but i tried at least.
PHP Code:
public GetPlayers()
{
    
//static terrorists, counter_terrorists
 
    
for(new id 1id <= get_maxplayers(); id++)
    {
        if(
is_user_connected(id) && is_user_alive(id))
        {
            if(
cs_get_user_team(id) == CS_TEAM_T)
            {
                
cs_set_user_team(id, (CS_TEAM_T terrorists++))
                
//terrorists++
            
}
 
            if(
cs_get_user_team(id) == CS_TEAM_CT)
            {
                
cs_set_user_team(id, (CS_TEAM_CT counter_terrorists++))
                
//counter_terrorists++
            
}
        }
    }

    if(
terrorists && counter_terrorists)
    {
        return 
PLUGIN_CONTINUE
    
}
 
    return 
PLUGIN_HANDLED

If you don't know if it will work then you shouldn't try and help all your doing is going to confuse the OP.
__________________
Blizzard_87 is offline
fysiks
Veteran Member
Join Date: Sep 2007
Location: Flatland, USA
Old 03-21-2014 , 02:42   Re: GetPlayers Bugging
Reply With Quote #4

Never use get_maxplayers() or get_playersnum() in or as part of a for loop. Also, if a user is alive, they are connected (the is_user_alive() check already checks if they are connnected).

Anyways, you should use the get_players() native. This will already give you only players that are connected.

Also, your function doesn't do anything and your description of what you want makes no sense. You need to explain in detail what you are wanting (something that can be understood).

@Baws, wow, that is just horrible. Stop trying to help people when you have no idea of what you are doing.
__________________
fysiks is offline
Kellan123
AlliedModders Donor
Join Date: Aug 2012
Old 03-21-2014 , 16:09   Re: GetPlayers Bugging
Reply With Quote #5

Quote:
Originally Posted by fysiks View Post
Never use get_maxplayers() or get_playersnum() in or as part of a for loop. Also, if a user is alive, they are connected (the is_user_alive() check already checks if they are connnected).

Anyways, you should use the get_players() native. This will already give you only players that are connected.

Also, your function doesn't do anything and your description of what you want makes no sense. You need to explain in detail what you are wanting (something that can be understood).

@Baws, wow, that is just horrible. Stop trying to help people when you have no idea of what you are doing.
shh, its only working bool: no public...
Kellan123 is offline
Baws
Veteran Member
Join Date: Oct 2012
Old 03-21-2014 , 17:18   Re: GetPlayers Bugging
Reply With Quote #6

I at least try to help... Sometimes you guys just ignore topics that's why.
Anyways, i'll stop sorry for confusing you kellan!
__________________
Like my clean plugins and work?
Baws is offline
fysiks
Veteran Member
Join Date: Sep 2007
Location: Flatland, USA
Old 03-21-2014 , 18:16   Re: GetPlayers Bugging
Reply With Quote #7

Quote:
Originally Posted by Kellan123 View Post
shh, its only working bool: no public...
What? If you want help, you need to explain in detail what you are wanting.

Quote:
Originally Posted by baws View Post
I at least try to help... Sometimes you guys just ignore topics that's why.
Anyways, i'll stop sorry for confusing you kellan!
When you make fundamental mistakes, it is counter-productive. Trying to help is great but you can't just keep posting random code. So, if you are going to try to help when you don't know what you are doing, you should test the code to make sure that it works first.
__________________

Last edited by fysiks; 03-21-2014 at 18:16.
fysiks is offline
Baws
Veteran Member
Join Date: Oct 2012
Old 03-21-2014 , 18:43   Re: GetPlayers Bugging
Reply With Quote #8

Okay thanks man for letting me know.
__________________
Like my clean plugins and work?
Baws is offline
OnePL
BANNED
Join Date: May 2012
Location: GB
Old 03-22-2014 , 00:08   Re: GetPlayers Bugging
Reply With Quote #9

PHP Code:
#include <amxmodx>

#define USE_GETPLAYERS // uncommented - get_players, commented - loop for

public plugin_init() register_clcmd("say /status""clcmd_status");

public 
clcmd_status(id) {
    
client_print(id3"Alive TT: %i, Alive CT: %i, All TT: %i, All CT: %i"GetPlayers(11), GetPlayers(12), GetPlayers(01), GetPlayers(02));
}

#if defined USE_GETPLAYERS

stock GetPlayers(aliveteam) {
    new 
players[32], num;
    
get_players(playersnumalive "aceh" "ceh"team == "TERRORIST" "CT");
    return 
num;
}

#else

stock GetPlayers(aliveteam) {
    static 
maxplmaxpl get_maxplayers();
    for(new 
1<= maxpli++) {
        if(!
is_user_connected(i) || get_user_team(i) != team) continue;
        if(
alive && !is_user_alive(i)) continue;

        
i++;
    }
    return 
i;
}

#endif 

Last edited by OnePL; 03-22-2014 at 00:10.
OnePL is offline
Send a message via ICQ to OnePL Send a message via AIM to OnePL Send a message via Yahoo to OnePL Send a message via Skype™ to OnePL
claudiuhks
Yam Inside®™℠
Join Date: Jan 2010
Location: Living Randomly
Old 03-22-2014 , 12:20   Re: GetPlayers Bugging
Reply With Quote #10

Regarding your first message, you need to zero your variables before using them. They are declared as static, and they never reset themselves until plugin reloads.

PHP Code:
GetPlayersCount(Team)
{
  static 
Players 0Player 0;

  
Players 0;

  for (
Player 1Player <= get_maxplayers(); Player++)
  {
    if (
is_user_connected(Player) && get_user_team(Player) == Team)
      
Players++;
  }

  return 
Players;

__________________

Last edited by claudiuhks; 03-22-2014 at 12:23.
claudiuhks is offline
Send a message via MSN to claudiuhks Send a message via Yahoo to claudiuhks Send a message via Skype™ to claudiuhks
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 20:05.


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