Jump to content
Sign in to follow this  
630R93

cycle with count

Recommended Posts

Hi guys, I have this issue:

I have 5 enemies and I need to play radio msg when their count is 4 or less. I use:

_enemy = [npc1, npc2, npc3, npc4, npc5];

aliveEnemy = {alive _x} count _enemy;

if( aliveEnemy == 4 ) then {

player sideRadio "msg7" }

But I can´t reach it.I want to play it independently on any triggers or some other condition, just when their count is 4 or less. I know I can do it by cycle and I found that in sqf files it´s done by WHILE cycle, but I want to do it only once.

I would really appreciate any help, thank you very much:)

Share this post


Link to post
Share on other sites

I resolved it already, you can delete this.

Share this post


Link to post
Share on other sites

Why not share your solution?

Share this post


Link to post
Share on other sites

That didn´t came to my mind, I´ve been wake up all night, sorry.

Here´s answer from armaholic http://www.armaholic.com/forums.php?m=posts&q=22393 which I get,

and here´s my solution, but it seems that previous solution would be better, I was only tired to try it.

In one script in 1st trigger is :

_enemy = [npc1, npc2, npc3, npc4, npc5];

while { alive enemy_house } do {

aliveEnemy = {alive _x} count _enemy;

sleep 2

}

For 2nd trigger (no size) condition I have: aliveEnemy < 5 or damage player > 0 //cause messages shall came after contact

and in script of this trigger are just messages that I want to call:

soldier1 sideRadio "msg7";

sleep 5.24;

soldier1 sideRadio "msg8";

sleep 8.27;

Pilot1 sideRadio "msg9";

sleep 1.29

I´m not sure if it´s necessary to make while cycle for count, but I had some problems with it. Now I´m more interested how to forbid my units to report enemy without disabling all radio, but that´s another topic. I should go sleep now, hope this helps someone:)

Share this post


Link to post
Share on other sites

there is another, easier way. you dont need any script at all:

create a trigger and in its Condition field write this:

(!alive npc1) || (!alive npc2) || (!alive npc3) || (!alive npc4) || (!alive npc5) || (damage player > 0);

now you have 5 units, if one of them is dead, you have 4...

then if ncp1 dies, or ncp2 dies, or npc3.... then you have 4 units.

on the on act you write whatever you want...

Share this post


Link to post
Share on other sites
there is another, easier way. you dont need any script at all:

create a trigger and in its Condition field write this:

(!alive npc1) || (!alive npc2) || (!alive npc3) || (!alive npc4) || (!alive npc5) || (damage player > 0);

now you have 5 units, if one of them is dead, you have 4...

then if ncp1 dies, or ncp2 dies, or npc3.... then you have 4 units.

on the on act you write whatever you want...

Thanks man! That´s way better :)

Share this post


Link to post
Share on other sites

Please sign in to comment

You will be able to leave a comment after signing in



Sign In Now
Sign in to follow this  

×