Jump to content
Sign in to follow this  
SRBuckey5266

While loop doesn't sleep?

Recommended Posts

onMapSingleClick{
if(_shift) then {
	hint "Creating Fleet";

	_num = 2;
	_spacing = 150;
	_run = true;
	_pilots = [];

	player setPos _pos;
	_marker = createMarker [fleet_leaving, _pos];
	_target = createMarker [fleet_arrival, [(_pos select 0),(_pos select 1)+3100,(_pos select 2)]];

	for "_x" from 1 to _num do {
		//CODE SNIPPED

		_pilot = (group player) createUnit ["RU_Soldier_Pilot", _pos, [], 0, "NONE"]; _pilot moveInDriver _heli;

		[_pilot] join (group player);
		_pilots set [(count _pilots)+1, _pilot];
	};

	sleep 5;

	//tell them to move their asses
	{
		_x doMove (getMarkerPos "fleet_arrival");
	} foreach _pilots;

	//make me the leader so there's some peace between the troops, lol
	(group player) selectLeader player;

}
}

while { _run } do {
_hit = false;

{
	hint format["%1", ((getMarkerPos "fleet_arrival") distance _x)];
	sleep 10;
	if((getMarkerPos "fleet_arrival") distance _x >= 400) then {
		//_hit = true;
	};
} foreach _pilots;

//remove all
if(_hit) then {

	//remove vehicles
	{
		_objects = allMissionObjects _x;
		{ detach _x; deleteVehicle _x; _x setDamage 1 } foreach _objects;
	} foreach ["Su34", "Land_LHD_6", "Land_LHD_5", "Land_LHD_4", "Land_LHD_3", "Land_LHD_2", "Land_LHD_1", "M119_US_EP1", "AGS_UN_EP1", "M2StaticMG_US_EP1", "TOW_TriPod_US_EP1", "SearchLight_UN_EP1", "MV22", "Land_LHD_house_2", "Land_LHD_house_1", "AH6J_EP1"];

	//now we remove troops
	{
		_objects = allMissionObjects _x;
		{ detach _x; deleteVehicle _x; _x setDamage 1 } foreach _objects;
	} foreach ["Su34", "Land_LHD_6", "Land_LHD_5", "Land_LHD_4", "Land_LHD_3", "Land_LHD_2", "Land_LHD_1", "M119_US_EP1", "AGS_UN_EP1", "M2StaticMG_US_EP1", "TOW_TriPod_US_EP1", "SearchLight_UN_EP1", "MV22", "Land_LHD_house_2", "Land_LHD_house_1", "AH6J_EP1"];

	_run = false;

	hint "Cleaned";
};

sleep 5;
};

Whenever this code is ran, the while loop runs without stopping...crashing my game. Any ideas while the sleep fails?

Share this post


Link to post
Share on other sites

_pilots and _hit are defined within a specific scope and aren't going to be run outside that scope, so your while loop does practically nothing.

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  

×