Jump to content
Sign in to follow this  
hidden sniper

Make a script wait until trigger activates

Recommended Posts

Hi

I am fairly new to scripting and have written this sqf script to make a large amount of civilians flee a town which seems to work ok. However what I need to do now is to make the script or the activation of the script wait untill a trigger (called civfleestart) is activated so that they begin to move at the right time.

_civ = _this select 0;
_group = group _civ;

Sleep 2;

_waypoint1 = _group addWaypoint [getMarkerPos "civflee1"];

_waypoint1 setWaypointType "MOVE";

_waypoint1 setWaypointSpeed "full";

_waypoint1 setWaypointBehaviour "careless";

_waypoint2 = _group addWaypoint [getMarkerPos "civflee3"];

_waypoint2 setWaypointType "MOVE";

sleep 500;

{deletevehicle _x} foreach units _group;

This is whats written in the civillian units init box

[this] exec "civmove1.sqf"

I have tried searching and found some different ways to do this but I could not get them to work so I could do with an example. Also I could do with the deletion of the units based on when they get to the last waypoint rather than a rough timer if anyone can help with that too.

Thanks for any help!

Share this post


Link to post
Share on other sites

On top of the script write:

waitUntil {civfleestart};

To delete the unit once it reached its destination use:

waitUntil {unitReady _civ};

and then the delete command below that.

Modified script:

_civ = _this select 0;

waitUntil {civfleestart};
_civ move getMarkerPos "civflee1";
_civ setBehaviour "CARELESS";
_civ setSpeedMode "FULL";

waitUntil {(unitReady _civ)};
_civ move getMarkerPos "civflee3";

waitUntil {(unitReady _civ)};
deleteVehicle _civ;

If you call the script from a units init line you need to use:

nul=[this] exec "civmove1.sqf"

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  

×