Jump to content
Sign in to follow this  
jaenak

Group dead script

Recommended Posts

I've been messing with a script for a few hours now doing everything I have seen done and its not working. Can anybody help me with this? I'm at the place where I want to put my fist through the monitor.

What I'm trying to do is make a script that'll set a variable named "gd" to true when everyone in "groupe1" and "groupe2" are dead. But to make it even more universal so I can use it in other missions, have the line entered in the trigger line pass the group names to the script. Like

<table border="0" align="center" width="95%" cellpadding="0" cellspacing="0"><tr><td>Code Sample </td></tr><tr><td id="CODE">

[groupe1, groupe2] exec "GroupDead.sqs"

so the script would have

<table border="0" align="center" width="95%" cellpadding="0" cellspacing="0"><tr><td>Code Sample </td></tr><tr><td id="CODE">

_a = _this select 0

_b = _this select 1

then it would say if _a and _b are dead then gd = true

What I currently have is

<table border="0" align="center" width="95%" cellpadding="0" cellspacing="0"><tr><td>Code Sample </td></tr><tr><td id="CODE">

_a = _this select 0

_b = _this select 1

If Not Alive _a And Not Alive _b Then gd = true

And in the trigger init field I have

<table border="0" align="center" width="95%" cellpadding="0" cellspacing="0"><tr><td>Code Sample </td></tr><tr><td id="CODE">

[groupe1, groupe2] exec "GroupDead.sqs"

What am I doing wrong?

Share this post


Link to post
Share on other sites

This will work:

<table border="0" align="center" width="95%" cellpadding="0" cellspacing="0"><tr><td>Code Sample </td></tr><tr><td id="CODE">

_a = _this select 0

_b = _this select 1

?!( Alive _a )&& ! (Alive _b): gd = true

RED

Share this post


Link to post
Share on other sites
This will work:

<table border="0" align="center" width="95%" cellpadding="0" cellspacing="0"><tr><td>Code Sample </td></tr><tr><td id="CODE">

_a = _this select 0

_b = _this select 1

?!( Alive _a )&& ! (Alive _b): gd = true

RED

Would surprise me RED, since you pass 2 arrays..

<table border="0" align="center" width="95%" cellpadding="0" cellspacing="0"><tr><td>Code Sample </td></tr><tr><td id="CODE">_ar = (_this select 0) + (_this select 1)

#loop

_i = 0

#loop2

_unit = _ar select _i

?!alive _unit : _ar set [_i, _ar select ((count _ar)-1)], _ar resize (count _ar - 1)

? _i < (count _ar - 1): _i = _i + 1, goto "loop2"

~10

?count _ar > 0 : goto "loop"

gd = true

exit

this script runs continuous and checks every 10 seconds if the condition is met.

Share this post


Link to post
Share on other sites

what about:

<table border="0" align="center" width="95%" cellpadding="0" cellspacing="0"><tr><td>Code Sample </td></tr><tr><td id="CODE">_a = _this select 0

_b = _this select 1

@( ((count units _a)==0) && ((count units _b)==0) )

gd = true

or

<table border="0" align="center" width="95%" cellpadding="0" cellspacing="0"><tr><td>Code Sample </td></tr><tr><td id="CODE">_a = _this select 0

_b = _this select 1

#Loop1

~10

?( ((count units _a)>0) && ((count units _b)>0) ): goto "Loop1"

gd = true

perhaps this will not work if either of the two groups are zero?

Share this post


Link to post
Share on other sites

or

<table border="0" align="center" width="95%" cellpadding="0" cellspacing="0"><tr><td>Code Sample </td></tr><tr><td id="CODE">_a = _this select 0

_b = _this select 1

#Loop1

~10

?{alive _x} count units _a + units _b == 0:goto "loop1"

gd=true

I experienced that sometimes (count units _a)==0 is not 0 even all group units are dead.

Share this post


Link to post
Share on other sites

Yes BartJan is right, sometimes it takes minutes before count of a group reaches zero after everyon is killed. Perhaps it is when someone looks at the last deceased man? tounge_o.gif

Share this post


Link to post
Share on other sites
This will work:

<table border="0" align="center" width="95%" cellpadding="0" cellspacing="0"><tr><td>Code Sample </td></tr><tr><td id="CODE">

_a = _this select 0

_b = _this select 1

?!( Alive _a )&& ! (Alive _b): gd = true

RED

Would surprise me RED, since you pass 2 arrays..

<table border="0" align="center" width="95%" cellpadding="0" cellspacing="0"><tr><td>Code Sample </td></tr><tr><td id="CODE">_ar = (_this select 0) + (_this select 1)

#loop

_i = 0

#loop2

_unit = _ar select _i

?!alive _unit : _ar set [_i, _ar select ((count _ar)-1)], _ar resize (count _ar - 1)

? _i < (count _ar - 1): _i = _i + 1, goto "loop2"

~10

?count _ar > 0 : goto "loop"

gd = true

exit

this script runs continuous and checks every 10 seconds if the condition is met.

Opps must have had a frozen brain when I wrote that post crazy_o.gif

RED

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  

×