AlliedModders

AlliedModders (https://forums.alliedmods.net/index.php)
-   Scripting Help (https://forums.alliedmods.net/forumdisplay.php?f=11)
-   -   Checking if a bool is true for all Terrorists (https://forums.alliedmods.net/showthread.php?t=131705)

GXLZPGX 07-07-2010 22:49

Checking if a bool is true for all Terrorists
 
How would I check if all T's have:

PHP Code:

gIsFrozen[id] = true 


Bugsy 07-07-2010 23:36

Re: How to check if bool is true for all T's?
 
Use a loop

Or

Use bit flags for your bools instead of an array. You can then compare the value of this var with a var holding bit flags for all players on terrorist team.

GXLZPGX 07-08-2010 02:59

Re: How to check if bool is true for all T's?
 
Quote:

Originally Posted by Bugsy (Post 1231585)
Use a loop

Or

Use bit flags for your bools instead of an array. You can then compare the value of this var with a var holding bit flags for all players on terrorist team.

Same thing wrecked told me. Example?

SnoW 07-08-2010 07:37

Re: How to check if bool is true for all T's?
 
Quote:

Originally Posted by GXLZPGX (Post 1231665)
Same thing wrecked told me. Example?

PHP Code:

new Terrorists;

TerroristJoinTeamid )
     
Terrorists |= ( << id );

TerroristLeaveTeamid )
     
Terrorists &= ~( << id );

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



Bugsy 07-08-2010 10:06

Re: How to check if bool is true for all T's?
 
You will have an issue when id=32.

PHP Code:

new Terrorists;

TerroristJoinTeamid )
     
Terrorists |= ( << ( id 31 ) );

TerroristLeaveTeamid )
     
Terrorists &= ~( << ( id 31 ) ); 


Brreaker 07-08-2010 10:42

Re: Checking if a bool is true for all Terrorists
 
why not ?
PHP Code:

if(cs_get_user_team(id) == CS_TEAM_T && gIsFrozen[id] = true ) { 
 
//User is terrorist and has gIsFrozen[id] = true 



Bugsy 07-08-2010 11:54

Re: Checking if a bool is true for all Terrorists
 
You can do this many ways but the above method is more efficient.

SnoW 07-08-2010 13:56

Re: Checking if a bool is true for all Terrorists
 
Quote:

Originally Posted by Bugsy (Post 1231940)
You will have an issue when id=32.

You are right.

Quote:

Originally Posted by Brreaker (Post 1231975)
why not ?
PHP Code:

if(cs_get_user_team(id) == CS_TEAM_T && gIsFrozen[id] = true ) { 
 
//User is terrorist and has gIsFrozen[id] = true 



You're using the wrong operator.

GXLZPGX 07-08-2010 14:31

Re: Checking if a bool is true for all Terrorists
 
Alright, the one Brreaker posted is the one I was thinking about. But wrecked said there was a better way. But since he isn't on, I guess I have to use this one for now.

Now for the mod I'm working on, I want it to end the round when the bool is true for all T's and select two random CT's for the beginning of next round, how would I do this?

SnoW 07-08-2010 16:25

Re: Checking if a bool is true for all Terrorists
 
Quote:

Originally Posted by GXLZPGX (Post 1232213)
Alright, the one Brreaker posted is the one I was thinking about. But wrecked said there was a better way. But since he isn't on, I guess I have to use this one for now.

Excuse me, but why do you totally ignore everything I and Bugsy have posted in this thread?


All times are GMT -4. The time now is 07:14.

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