# How to count number of computer players?

#### Nichilus

Level 22
Try this:
• Actions
• Set count = 0
• For each (Integer loopInt) from 1 to 12, do (Actions)
• Loop - Actions
• If (All Conditions are True) then do (Then Actions) else do (Else Actions)
• If - Conditions
• ((Player(loopInt)) controller) Equal to Computer
• Then - Actions
• Set count = (count + 1)
• Else - Actions

#### Vinz

Level 74
Question invalid.
You know variables, but don't know how to explore with possible functions?
Inadmissible. All you ask are the most obvious.

Even someone newer than you would guess the inefficient but easier player function.

You even asked 'How to know if an integer variable is equal to 0'
when that is the first integer comparison GUI function.

#### stan0033

Banned
Level 30
Try this:
• Actions
• Set count = 0
• For each (Integer loopInt) from 1 to 12, do (Actions)
• Loop - Actions
• If (All Conditions are True) then do (Then Actions) else do (Else Actions)
• If - Conditions
• ((Player(loopInt)) controller) Equal to Computer
• Then - Actions
• Set count = (count + 1)
• Else - Actions

If I Put message in the end the number will be 12.
• Game - Display to (All players) the text: (String(loopInt))
Question invalid.
You know variables, but don't know how to explore with possible functions?
Inadmissible. All you ask are the most obvious.

Even someone newer than you would guess the inefficient but easier player function.

You even asked 'How to know if an integer variable is equal to 0'
when that is the first integer comparison GUI function.

Who do you think you are to judge me?

#### Chaosy

Tutorial Reviewer
Level 40
@stan
wrathion has been kinda rude lately I dont know if he hate christmas or something.

however he got a point, this is very very simple stuff that everyone knows. I suggest going to some tutorials. You get such disrespect if you got over 100 posts and dont know the basics.

"if I Put message in the end the number will be 12." I thought it would write 11 but the script he posted is correct.

#### Xonok

Level 21
It's because you printed the wrong variable. Try printing count.

#### Nichilus

Level 22
If I Put message in the end the number will be 12.
• Game - Display to (All players) the text: (String(loopInt))
Depends where you put it.
If you put it inside the "loop-actions" part of the "For integer loop", then it will actually show 12 messages.
If you put it outside "loop-actions" block, it will show only once and it will be like you wrote number 12.

The GUI function looks like this:
For each (integer variable) from X to Y do (Actions)
What you have to set up is the integer variable - in the trigger I posted that variable would be called loopInt
and set X and Y, where (X < Y), else it would not loop at all.
In the trigger I posted X would have value 1 and Y would have value 12.

Now it works like this: When you first start this loop, loopInt variable will be assigned number equal to X and it will do all those actions which are inside the "Loop - Actions" block. In the trigger I posted inside the "Loop - Actions" block is that If/Then/Else function.

Once all actions in the "Loop - Actions" block has been completed, the integer variable loopInt will have its value increased by 1 and it will once again do all those actions in the "Loop - Actions" block. Then once that is finished, loopInt will have its value increased by 1 yet again... and this process will repeat and repeat until loopInt value becomes greater than Y, in which case it will stop and it will no longer start all those actions in the "Loop - Actions" block; instead the trigger will go on without going back into the loop.

This is why loopInt has value 12 when you put it outside the Loop-Actions block.
However what you are interested in should be the "Count" variable, which contains the actual amount of Computer players.

#### Maker

Level 37
Try adding Player slot status - player is playing condition.

Replies
3
Views
766
Replies
3
Views
624
Replies
5
Views
6K
Replies
4
Views
488