Jump to content
Sign in to follow this  
Op4 BuhBye

Script help

Recommended Posts

I made a chopper script to drop some troops that will be players on a deticated server and it works fine up to checking if they got out. Once they are out it just sits there. Any ideas?

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

helo1 flyinheight 0

?(not(w1 in helo1) and (w2 in helo1) and (w3 in helo1) and (w4 in helo1) and (w5 in helo1)) : goto "leave"

~1

goto "drop"

#leave

helo1 domove getpos gone1

helo1 flyinheight 30

helo1 setspeedmode "FULL"

?helo1 distance gone1 < 200 : goto "empty"

~1

goto "leave"

#empty

deletevehicle helo1

exit

Thanx.

Share this post


Link to post
Share on other sites

Uhm. First check ranking of operators . "not" needs to be in parenthesis. Then:

Better use an @op

@( NOT( w1 in helo1 OR w2 in helo1 ) )

will make the script wait for the cond in @cond

Share this post


Link to post
Share on other sites

Thanx for the reply Manday. Not is in parenthesis just like you have it. And if I use the @, I get an error type bool expected switch.

I actually changed the syntax to

<table border="0" align="center" width="95%" cellpadding="0" cellspacing="0"><tr><td>Code Sample </td></tr><tr><td id="CODE">@(not((w1 in helo1) and (w2 in helo1) and (w3 in helo1) and (w4 in helo1) and (w5 in helo1))) : goto "leave"

Share this post


Link to post
Share on other sites

I think ManDay meant to use an @ statement and not simply replace ? with @.

A complete rewrite would be:

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

helo1 flyinheight 0

@(not ((w1 in helo1) and (w2 in helo1) and (w3 in helo1) and (w4 in helo1) and (w5 in helo1)) )

helo1 domove getpos gone1

helo1 flyinheight 30

helo1 setspeedmode "FULL"

@(helo1 distance gone1 < 200)

deletevehicle helo1

exit

Share this post


Link to post
Share on other sites

Strange. I cannot find the "@"-Operator in the wiki no more huh.gif

But I have a further "BTW" for you:

Use the ! Operator instead of the "Word" NOT and the && Operator instead of AND (|| instead of OR). This will make the whole line look a bit mire structured because then you can distinguish variables and operator a bit easier.

---edit---

icon_rolleyes.gif lol, yes indeed. Didnt read your code-snipped. Of course. Sorry I thought this was obvious so i completely forgot to tell you the @operator has a different usage

Share this post


Link to post
Share on other sites

This is what I have and he still just sits there after you get out.

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

helo1 flyinheight 0

@(!((w1 in helo1) && (w2 in helo1) && (w3 in helo1) && (w4 in helo1) && (w5 in helo1)))

helo1 domove getpos gone1

helo1 flyinheight 30

helo1 setspeedmode "FULL"

@helo1 distance gone1 < 200

deletevehicle helo1

exit

Share this post


Link to post
Share on other sites

*cought* || not && wink_o.gif

Its either

not( ... or ... or ... or ... )

or

... nor ... nor ... nor ...

or

( not ... ) and ( not ... ) and ( not ... )

^ all of above means the same. None of the "..."s is supposed to be true. I dont know whether "nor" is supported by arma. but as wel already pointed out you better use the first variant with !( .. || ... || ... )

Share this post


Link to post
Share on other sites

Offtopic:

The @-operator

It has been partly removed as BIS want more ppl to use .sqf scripting for ARMA.

Where @ is replaced with "waitUntil"

e.g.

waitUntil{somethingHasHappened}

Something cool with this is that you are able to add stuff within the body(block) like

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

waitUntil{

someThingElse=false;

for[{_i=0},{_i < 5},{_i=_i+1}]do{

player groupChat format["SPAM %1!!",_i];

};

SomeThingHappened

};

player groupChat "BBQ!!";

Which will result in

spam 0!!

spam 1!!

spam 2!!

spam 3!!

spam 4!!

and when SomeThingHappened=true

BBQ!

[edit]

Be aware tho how you access it.

This is wrong. waitUntil works only in a script (asynchronous execution). You need to use not call, which is synchronous, but spawn or execVM.

[edit2]

Also note that there is no ";" after SomeThingHappened as it is the "return value" of the waitUntil-thing.

Much the same as a functions return value.

Share this post


Link to post
Share on other sites

Ok I tried

<table border="0" align="center" width="95%" cellpadding="0" cellspacing="0"><tr><td>Code Sample </td></tr><tr><td id="CODE">@(!(w1 in helo1) && !(w2 in helo1) && !(w3 in helo1) && !(w4 in helo1) && !(w5 in helo1))

Still sits there.

<table border="0" align="center" width="95%" cellpadding="0" cellspacing="0"><tr><td>Code Sample </td></tr><tr><td id="CODE">@((!w1 in helo1) && (!w2 in helo1) && (!w3 in helo1) && (!w4 in helo1) && (!w5 in helo1))

Gives error.

Ive only got about 3 hairs left here.lol

Taurus I know 0 about SQF and the rest is in SQS so I cant mixem.

Share this post


Link to post
Share on other sites

rofl.gif Oh dude. Please try this: If it doesnt work just go for ONE single hair so there are still 2 trys left biggrin_o.gif

@( !( ( w1 in helo1 )||( w2 in helo1 )||( w3 in helo1 )||( w4 in helo1 )||( w5 in helo1 ) ) )

Share this post


Link to post
Share on other sites

Op4 BuhBye

Try splitting it up and assigning the booleans into variables to ease things up, like

_bol1 = w1 in helo1

_bol2 = w2 in helo1

_bol3 = w3 in helo1

_bol4 = w4 in helo1

_bol5 = w5 in helo1

and then place it in your @-operator thing.

Maybe the code engine translates it wrongly.

Also, maybe BIS sells wigs too wink_o.gif

[edit]

The SQF and SQS doesn't differ that much, just keep entering ";" after each line and you'll do fine.

Plus that theres alot of "cool" stuff which you can't use when creating SQS-scripts, like the waitUntil thing I described above.

Share this post


Link to post
Share on other sites

I cant use the "or" cause if 1 person gets out it will leave. The "or" here would mean any one of the players and I need to make sure they are all out.

Share this post


Link to post
Share on other sites

Just try it thumbs-up.gif

... or ... or ... => Is ANYBODY in?

not( ... or ... or ... ) => Is NO ONE in?

Share this post


Link to post
Share on other sites

That didnt work either. Touches down and lifts off then hovers.

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

_c2 = w2 in helo1

_c3 = w3 in helo1

_c4 = w4 in helo1

_c5 = w5 in helo1

helo1 flyinheight 30

helo1 setbehaviour "stealth"

helo1 domove getpos start1

helo1 setspeedmode "NORMAL"

#loop

?helo1 distance start1 < 300 : goto "land"

~0.5

goto "loop"

#land

helo1 setspeedmode "NORMAL"

helo1 land "GET OUT"

_height = getpos helo1 select 2

?_height < 1 : goto "drop"

~0.5

goto "land"

#drop

helo1 flyinheight 0

@(!(_c1) || (_c2) || (_c3) || (_c4) || (_c5))

helo1 domove getpos gone1

helo1 flyinheight 30

helo1 setspeedmode "FULL"

@helo1 distance gone1 < 200

deletevehicle helo1

exit

Share this post


Link to post
Share on other sites

Just a thought here.

What about

@(!((_c1) || (_c2) || (_c3) || (_c4) || (_c5)))

?

as

!(_c1) will only be "not _c1" for the first condition.

And it will think the other ones are true?

You also wanted? this behavior in your first example.

@(!((w1 in helo1) && (w2 in helo1) && (w3 in helo1) && (w4 in helo1) && (w5 in helo1)))

Share this post


Link to post
Share on other sites

Don't put your check at the beginning of the script because the values will never change once it is assigned to c1, etc..

here, since your still having trouble:

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

@({_x in helo1} count [w1,w2,w3,w4,w5] == 0)

helo1 domove getpos gone1

helo1 flyinheight 30

helo1 setspeedmode "FULL"

@(helo1 distance gone1 < 200)

deletevehicle helo1

exit

[Edit...] I suppose I should add an explanation:

the "count" command can be used with arrays and a condition. In this case.. [w1,w2,w3,w4,w5] is the array and {_x in helo1} is the condition. What this command does is check the condition against every value in the array ...

i.e. "Is w1 in helo1?", "Is w2 in helo1?", etc... by replacing the _x variable with whatever value is next in the array.

And adds up the total number of times this value is true. The result should be a number greater than 0 if there are ANY of those specified units in helo1. It will be 0 in the event there are none in helo1.

Share this post


Link to post
Share on other sites

Thanx CrashDome but sad_o.gif again it doesn't work. The chopper just hovers over the LZ and doesn't land.

I dont mind saying at this point that this is nothing short of absurd! I have 5 people helping me, 90% of the ideas give no error, It still doesn't work and all because AI choppers wont land on a deticated server with a WP. This is nice!

Share this post


Link to post
Share on other sites

Ok guys, You all have been awesome and I really thank everyone of you. Here is the update. As it turns out 99% of the suggestions as well as my original check works.

The issue is that once the chopper is empty it doesn't move on to the next "doMove" command. It gets hung there for some reason. Any Ideas on this? I ran into this in OFP with using the domove more than once on a unit. I never figured it out though.

The current script is...

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

helo1 setvelocity [0,50,0]

helo1 setbehaviour "stealth"

helo1 domove getpos start1

helo1 setspeedmode "NORMAL"

#loop

?helo1 distance start1 < 300 : goto "land"

~0.5

goto "loop"

#land

helo1 setspeedmode "NORMAL"

helo1 land "GET OUT"

_height = getpos helo1 select 2

?_height < 1 : goto "drop"

~0.5

goto "land"

#drop

helo1 flyinheight 0

@({_x in helo1} count [w1,w2,w3,w4,w5] == 0)

helo1 domove getpos gone1

helo1 flyinheight 30

helo1 setspeedmode "FULL"

@helo1 distance gone1 < 200

deletevehicle helo1

exit

Share this post


Link to post
Share on other sites

I figured it out and Im dumb! Replaced "GetPos" with "GetMarkerPos "done1". Works great! Thank you sooo much for the help! yay.gif

Share this post


Link to post
Share on other sites
I figured it out and Im dumb! Replaced "GetPos" with "GetMarkerPos "done1". Works great! Thank you sooo much for the help! yay.gif

Just wanted to say that after I read your first postings again biggrin_o.gif

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  

×