Raised This Month: $ Target: $400
 0% 

Checking if a bool is true for all Terrorists


Post New Thread Reply   
 
Thread Tools Display Modes
Bugsy
AMX Mod X Moderator
Join Date: Feb 2005
Location: NJ, USA
Old 07-08-2010 , 16:36   Re: Checking if a bool is true for all Terrorists
Reply With Quote #11

Didn't you say the method that I suggested is the same that wrecked suggested? Did you see what Snow and I posted?
__________________
Bugsy is offline
GXLZPGX
Veteran Member
Join Date: Sep 2009
Old 07-08-2010 , 16:37   Re: Checking if a bool is true for all Terrorists
Reply With Quote #12

Quote:
Originally Posted by Bugsy View Post
Didn't you say the method that I suggested is the same that wrecked suggested? Did you see what Snow and I posted?
Where should I place the code? Such as..

PHP Code:
public client_PreThink()
{
     new 
Terrorists

     
TerroristJoinTeamid 
          
Terrorists |= ( << id ); 

     
TerroristLeaveTeamid 
          
Terrorists &= ~( << id ); 

     if( ( 
Terrorists VariableThatHoldsFrozenPlayers ) == Terrorists 
     { 
          
//All terrorists are frozen 
     
}

__________________
Currently accepting payment US DOLLARS ONLY for custom plugins, contact me through PM.

Last edited by GXLZPGX; 07-08-2010 at 16:39.
GXLZPGX is offline
Bugsy
AMX Mod X Moderator
Join Date: Feb 2005
Location: NJ, USA
Old 07-08-2010 , 19:11   Re: Checking if a bool is true for all Terrorists
Reply With Quote #13

Not even close, you need to use a little logic.

Firstly, you need to create a hook for when a player changes team, in this hook you use the code above for TerroristJoinTeam. When a player changes team (from terrorist to CT\Spec) or disconnects, use the TerroristLeaveTeam code. Hooking team change can be found on the forums, search before asking how to do this.

Maybe this will help
PHP Code:
new g_Terrorists;
new 
g_Frozen;

#define SetFlag(%1,%2)    (%1 |= (1<<(%2&31)))
#define ClearFlag(%1,%2)    (%1 &= ~(1<<(%2&31)))

//Player joins terrorist team
SetFlagg_Terrorists id );

//Player changes to CT\disconnects
ClearFlagg_Terrorists id );

//Player gets frozen
SetFlagg_Frozen id );

//Player gets un-frozen
ClearFlagg_Frozen id );

if( ( 
g_Terrorists g_Frozen ) == g_Terrorists 

    
//All terrorists are frozen 

__________________
Bugsy is offline
GXLZPGX
Veteran Member
Join Date: Sep 2009
Old 07-09-2010 , 03:38   Re: Checking if a bool is true for all Terrorists
Reply With Quote #14

Mmk so I've found out how to work Snows method fine. But TerroristJoinTeam isn't a function.

Couldn't I use:

PHP Code:
public join_teamid )
{
    if( 
cs_get_user_teamid ) == CS_TEAM_T )
        
Terrorists |= ( << ( id 31 ) );
        
    if( 
cs_get_user_teamid ) == CS_TEAM_CT )
        
Terrorists &= ~( << ( id 31 ) );    

and join_team is whats executed when TeamInfo event is called.
__________________
Currently accepting payment US DOLLARS ONLY for custom plugins, contact me through PM.

Last edited by GXLZPGX; 07-09-2010 at 04:19.
GXLZPGX is offline
Spunky
Senior Member
Join Date: May 2008
Location: Orlando, Fl.
Old 07-09-2010 , 06:43   Re: Checking if a bool is true for all Terrorists
Reply With Quote #15

No, that removes a flag even if a terrorist hasn't left the team. You'll get extremely inaccurate results.
Spunky is offline
Send a message via AIM to Spunky
SnoW
Veteran Member
Join Date: Oct 2008
Location: Finland WisdomNuggets: 8
Old 07-09-2010 , 06:45   Re: Checking if a bool is true for all Terrorists
Reply With Quote #16

Quote:
Originally Posted by GXLZPGX View Post
But TerroristJoinTeam isn't a function.
False
SnoW is offline
Send a message via MSN to SnoW
Bugsy
AMX Mod X Moderator
Join Date: Feb 2005
Location: NJ, USA
Old 07-09-2010 , 08:45   Re: Checking if a bool is true for all Terrorists
Reply With Quote #17

Doing it this way is better than what you posted; if they join spec or even disconnect (I believe this calls TeamInfo for unassigned (0) team) they will be removed from the Terrorist variable. You can also use read_data() to detect the team in join_team instead of cs_get_user_team(). Why not use the macros I posted? This way you can use the same code to set a player as terrorist or frozen without re-writing the code.

Untested
PHP Code:
register_event"TeamInfo" "fwPlayerJoinedTeam" "a" );

public 
fwPlayerJoinedTeam( )
{
    new 
szTeam] , id;

    
id read_data);
    
read_dataszTeam charsmaxszTeam ) );

    if ( 
szTeam] == 'T' )
        
Terrorists |= ( << ( id 31 ) );
    else
        
Terrorists &= ~( << ( id 31 ) );

__________________

Last edited by Bugsy; 07-09-2010 at 09:22.
Bugsy is offline
GXLZPGX
Veteran Member
Join Date: Sep 2009
Old 07-09-2010 , 18:44   Re: Checking if a bool is true for all Terrorists
Reply With Quote #18

Quote:
Originally Posted by SnoW View Post
False
You're such a nuisance to the forums. You can't just say "False," you need to explain as to why it is false. Because it doesn't seem to work when I compile it using TerroristJoinTeam( id )


Quote:
Originally Posted by Bugsy View Post
Doing it this way is better than what you posted; if they join spec or even disconnect (I believe this calls TeamInfo for unassigned (0) team) they will be removed from the Terrorist variable. You can also use read_data() to detect the team in join_team instead of cs_get_user_team(). Why not use the macros I posted? This way you can use the same code to set a player as terrorist or frozen without re-writing the code.

Untested
PHP Code:
register_event"TeamInfo" "fwPlayerJoinedTeam" "a" );

public 
fwPlayerJoinedTeam( )
{
    new 
szTeam] , id;

    
id read_data);
    
read_dataszTeam charsmaxszTeam ) );

    if ( 
szTeam] == 'T' )
        
Terrorists |= ( << ( id 31 ) );
    else
        
Terrorists &= ~( << ( id 31 ) );

Will try it.
__________________
Currently accepting payment US DOLLARS ONLY for custom plugins, contact me through PM.
GXLZPGX is offline
wrecked_
Veteran Member
Join Date: Jan 2010
Location: New York (GMT-5)
Old 07-09-2010 , 18:54   Re: Checking if a bool is true for all Terrorists
Reply With Quote #19

Using bits isn't completely necessary. You can use this to check if a full team is frozen:

Code:
bool:IsTeamFrozen( CsTeams:Team ) {     new id;         new iPlayers[32];     new iNum;         get_players( iPlayers, iNum );         for( new i = 0; i < iNum; i++ )     {         id = iPlayers[i];                 if( ( cs_get_user_team( id ) == Team ) && !gIsFrozen[id] )             return false;     }         return true; }
__________________
[ Paid Requests ]
DO NOT PM ME ABOUT BLOCKMAKER
NO PRIVATE SUPPORT
wrecked_ is offline
Bugsy
AMX Mod X Moderator
Join Date: Feb 2005
Location: NJ, USA
Old 07-09-2010 , 19:10   Re: Checking if a bool is true for all Terrorists
Reply With Quote #20

There are countless ways to do this, though using the bit-field method is probably most efficient. Of course this all depends on how often he needs to check if a team is frozen. If it is only called once a round or some other infrequent interval, wreckeds method is fine. If called frequently I would use the bit-field method.
__________________
Bugsy 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 07:14.


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