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

[TF2] Get Alive Players Count


Post New Thread Reply   
 
Thread Tools Display Modes
Author Message
Otokiru
Senior Member
Join Date: Apr 2012
Old 04-27-2012 , 13:38   [TF2] Get Alive Players Count
Reply With Quote #1

Hi, need help with coding on how to check the number of alive players on a particular team.
E.g

If GetAlivePlayers on blueTeam == 1 {
do something;
}
Otokiru is offline
Patrick Star
Junior Member
Join Date: Apr 2012
Old 04-27-2012 , 13:55   Re: [TF2] Get Alive Players Count
Reply With Quote #2

Not quite sure either but this might help , it counts the number of people in a certain team:
GetTeamClientCount
Get the id's of all the people in that certain team and then
IsPlayerAlive


Good luck and hope I helped.

Edit : Well - I can see that your server is Saxton and by that I think you are trying to see if the Saxton is still alive. that could make the job much easier. I bet that in saxton there is already a name for it and therefore all you have to do is
if (IsPlayerAlive(NAMEOFSAXTON))
{

// code

}

Last edited by Patrick Star; 04-27-2012 at 14:00.
Patrick Star is offline
Otokiru
Senior Member
Join Date: Apr 2012
Old 04-27-2012 , 14:18   Re: [TF2] Get Alive Players Count
Reply With Quote #3

Quote:
Originally Posted by Patrick Star View Post
Not quite sure either but this might help , it counts the number of people in a certain team:
GetTeamClientCount
Get the id's of all the people in that certain team and then
IsPlayerAlive


Good luck and hope I helped.

Edit : Well - I can see that your server is Saxton and by that I think you are trying to see if the Saxton is still alive. that could make the job much easier. I bet that in saxton there is already a name for it and therefore all you have to do is
if (IsPlayerAlive(NAMEOFSAXTON))
{

// code

}
Thx but I'm adding bullets particles trails for the hale. My code works well but one of the issue is that one of the hale can re-spawn deadplayers onto the haleteam and whoever spawn in the haleteam also has the bullet particles trails which is not meant to be like that.

I manage to fix it by using the GetTeamClientCount. If GetTeamClientCount(BossTeam)==1 then attach the particle. It works too, but then, if a new player join the server, he will be switched to the blueTeam temporarily until the next roundstart which will make the GetTeamClientCount to 2 and won't attach the particles to the hale.... GAHHH!~
Otokiru is offline
Leonardo
Veteran Member
Join Date: Feb 2010
Location: 90's
Old 04-27-2012 , 14:30   Re: [TF2] Get Alive Players Count
Reply With Quote #4

Quote:
Originally Posted by Otokiru View Post
If GetAlivePlayers on blueTeam == 1 {
do something;
}
add this in .sp
Code:
stock GetTeamAliveCount( iTeamNum )
{
    new iCount;
    for( new iClient = 1; iClient <= MaxClients; iClient++ )
        if( IsClientInGame( iClient ) && GetClientTeam( iClient ) == iTeamNum && IsPlayerAlive( iClient ) )
            iCount++;
    return iCount;
}
__________________

Last edited by Leonardo; 04-28-2012 at 01:41.
Leonardo is offline
Powerlord
AlliedModders Donor
Join Date: Jun 2008
Location: Seduce Me!
Old 04-27-2012 , 15:15   Re: [TF2] Get Alive Players Count
Reply With Quote #5

btw, don't assume hale's team is always BLU. Always use the FF2_GetBossTeam native.

Better yet, use the FF2_OnSpecialSelected callback to set the bullet particles in the first place:

PHP Code:
public Action:FF2_OnSpecialSelectedindex, &SpecialNumString:SpecialName[])
{
    
// You may need to do a timer here

    // If you need a player client/entity, use this:
    
new client GetClientOfUserId(FF2_GetBossUserId(index));
    
// If you just need a userid, use this instead
    
new userid FF2_GetBossUserId(index);
    
// code to set particles here

Edit: This is apparently a pre-event, you may need a timer so the client entity is spawned first.
__________________
Not currently working on SourceMod plugin development.

Last edited by Powerlord; 04-27-2012 at 15:19.
Powerlord is offline
claudiuhks
Yam Inside®™℠
Join Date: Jan 2010
Location: Living Randomly
Old 04-27-2012 , 17:05   Re: [TF2] Get Alive Players Count
Reply With Quote #6

Quote:
Originally Posted by Leonardo View Post
add this in .sp
Code:
stock GetTeamAliveCount( iTeamNum )
{
    new iCount;
    for( new iClient = 0; iClient < MaxClients; iClient++ )
        if( IsClientInGame( iClient ) && GetClientTeam( iClient ) == iTeamNum && IsPlayerAlive( iClient ) )
            iCount++;
    return iCount;
}
No. You should start checking client one, not zero. Client may be equal with MaxClients. Stock is not required because this function will be definetly used in plugin. Use decl instead of new.

PHP Code:
GetAlivePlayersCountiTeam )
{
  
decl iCountiiCount 0;

  for( 
1<= MaxClientsi++ )
    if( 
IsClientInGame) && IsPlayerAlive) && GetClientTeam) == iTeam )
      
iCount++;

  return 
iCount;

__________________

Last edited by claudiuhks; 04-27-2012 at 17:05.
claudiuhks is offline
Send a message via MSN to claudiuhks Send a message via Yahoo to claudiuhks Send a message via Skype™ to claudiuhks
Cookies.net
Senior Member
Join Date: Jan 2011
Old 04-27-2012 , 17:26   Re: [TF2] Get Alive Players Count
Reply With Quote #7

Quote:
Originally Posted by claudiuhks View Post
No. You should start checking client one, not zero. Client may be equal with MaxClients. Stock is not required because this function will be definetly used in plugin. Use decl instead of new.

PHP Code:
GetAlivePlayersCountiTeam )
{
  
decl iCountiiCount 0;

  for( 
1<= MaxClientsi++ )
    if( 
IsClientInGame) && IsPlayerAlive) && GetClientTeam) == iTeam )
      
iCount++;

  return 
iCount;

Absolutely no reason to use "decl" instead of "new" in this case, read: http://wiki.alliedmods.net/Introduct...n#Golden_Rules
Cookies.net is offline
Dr. McKay
Sir Dr. SourceMod Plugin Approver Esq. Ltd. M.D. PhD
Join Date: Aug 2011
Location: Atlantis
Old 04-27-2012 , 17:45   Re: [TF2] Get Alive Players Count
Reply With Quote #8

Quote:
Originally Posted by Cookies.net View Post
Absolutely no reason to use "decl" instead of "new" in this case, read: http://wiki.alliedmods.net/Introduct...n#Golden_Rules
Yeah. As a rule of thumb, I only really decl Strings, since you have to fill them with a function of some kind anyway.
__________________
Dr. McKay is offline
Otokiru
Senior Member
Join Date: Apr 2012
Old 04-27-2012 , 22:00   Re: [TF2] Get Alive Players Count
Reply With Quote #9

Ok thanks all. Got it.
Otokiru is offline
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 18:12.


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