Jump to content
Sign in to follow this  
AwfulFalafel

Loops not looping

Recommended Posts

Okay, so I've searched and searched for an answer to this and nobody else seems to have this problem...

Every time I try to make a loop in a SQF it never works. Sometimes it plays through once, then stops. Right now I'm trying to get a group of units to essentially follow another group of units. This is what I have:

_chaser = _this select 0;

_chased = getpos (_this select 1);

_chasedobj = _this select 1

while {alive _chasedobj} do

{

(group _chaser) move _chased;

sleep 5;

};

In the trigger activation I have:

[(leader group uh60), (leader group ops_1)] exec "assault.sqf"

I've tried execVM -- didn't work. Tried doMove -- didn't work. Every single time the vehicle (uh60) moves once to the unit (ops_1) and then never does anything again. I thought maybe it was because it was a helo, so I tried a car. Same problem.

Please help me!!!

edit -- Oh and it says "Error generic error" before the "Sleep 5;" :/

Edited by AwfulFalafel

Share this post


Link to post
Share on other sites

You have to either use call or execVM to execute sqf. You've also added a sleep of 5 seconds, and that's quite a lot. If you constantly want the unit to move to the group try adding a sleep between 0.1 and 0.5.

Also, the script needs an identifier (or variable, I just call it identifier), so for example:

nul = [] execVM "somescript.sqf";

else it will return an error.

Also it is unnecessary to use (group _chaser), because you've already selected the leader of the group. Try out this

_chaser doMove (position _chased);

sleep 0.1;

This should continously move the group towards the position of the chased object.

Share this post


Link to post
Share on other sites
You have to either use call or execVM to execute sqf. You've also added a sleep of 5 seconds, and that's quite a lot. If you constantly want the unit to move to the group try adding a sleep between 0.1 and 0.5.

Also, the script needs an identifier (or variable, I just call it identifier), so for example:

nul = [] execVM "somescript.sqf";

else it will return an error.

Also it is unnecessary to use (group _chaser), because you've already selected the leader of the group. Try out this

_chaser doMove (position _chased);

sleep 0.1;

This should continously move the group towards the position of the chased object.

Cool thanks. I found out the problem was actually with the "_chased = getpos (_this select 1)" because it was picking up the original position when the script was activated and not updating the pos in the loop. But I used the execVM and removed the "group" and it worked great! I used sleep 5 cuz I figured there needed to be a delay to account for the group leader giving the order, and then giving the order again as commander of the vehicle (one of Arma's quirks, I suppose), but maybe I won't need to use that for a chopper or a group of infantry.

Also, what exactly is the difference between doMove and just Move?

Share this post


Link to post
Share on other sites

Move basically creates a waypoint for the group and that group moves there. (I actually thought about moveTo, which is a low-level command for a unit which basically tells that unit to move to given position with radio messages)

doMove is the exact opposite of moveTo, it basically overrides every move order and forces the unit to move to the position, without radio messages. Once the unit reaches that position though, it returns to the original group formation. Since you're only using 1 BlackHawk though it isn't much of a problem.

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  

×