Jump to content
Sign in to follow this  
Monan101

Following a unit

Recommended Posts

Ok so i've created a mission and need a support unit (ambulance) to be followed by a non grouped apc to protect it while it is executing the support command.

I can't just group the 2 units together because the protection team will exit their vehicle and i need them to stay inside to cover the medics.

any help would be appreciated, searched and didn't find what i was after.

Edited by Monan101

Share this post


Link to post
Share on other sites

Try this...

In "init.sqf" add the following line

support = 0;
null = [] execVM "Scripts\FollowMeds.sqf";

Then create a new script called "FollowMeds.sqf" somewhere in your mission folder. (I put all my scripts inside folder called "Scripts".

while {true} do
{
[indent]if (support == 1) then
{
[indent]Support doMove getPos Ambulance;
sleep 2;[/indent]


};[/indent]
};

And when you want the support vehicle to follow the ambulance, simply type

support = 1;

When you want the support to stop following the ambulance, just type

support = 0;

Basically FollowMeds.sqf will be in constant loop non stop. When it detects that the variable ' Support is equal to 1 ' it will execute the code. When it detects that the variable ' Support is not equal to 1 ' it will stop the code, until ' Support is equal to 1'.

This is probably not the best way to do it, but it should work.

Share this post


Link to post
Share on other sites

while {true} do
{
[indent]if ([b]support[/b] == 1) then
{
[indent][b]Support[/b] doMove getPos Ambulance;
sleep 2;[/indent]


};[/indent]
};

Hi... one glaring error there....you're using the variable support for two different things.

Share this post


Link to post
Share on other sites

Lol an error i made there.

I meant to have put

"unitName" doMove getPos Ambulance;

If i was using Squint for that code, it would have told me off. :P

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  

×