Jump to content

Recommended Posts

Hi all, so I am writing a script to randomly spawn 50 Quad-bikes across the map.

 

So far I have gotten them to spawn randomly but I can't get it to stop after 50 have spawned, It will keep running infinitely,

Vehiclespawn.sqf

while {true} do {

_vehNear	= getMarkerPos "center" nearObjects ["B_Quadbike_01_F", 20000];
_vehCount	= count _vehNear;

// searches whole map 
_sheds 		= getMarkerPos "center" nearObjects ["Land_Metal_Shed_F",20000];
_shed  		= _sheds select 0;
_position 	= _shed buildingPos 1;

if (_vehCount < 50) then {
	{
		_shed = _X;
		
			for "_n" do {
			_position = _shed buildingPos _n;
				if (str _position != "[0,0,0]") then {
					
					if (50 > random 442) then {
						_positionSafe = _position findEmptyPosition [0,5,"B_Quadbike_01_F"];
						_quad = "B_Quadbike_01_F" createVehicle _positionSafe;
						};
					};
				};
			sleep 0.5;
		}forEach _sheds;
	}
};	

I call for that through the init wit []execVM "Vehiclespawn.sqf";

 

Thanks ahead for the help! 

Edited by Theassassinzz
Added findEmptyPosition to stop vehicles from blowing up on spawn

Share this post


Link to post
Share on other sites

I tried adding 

. . . .
};
sleep 300;
exitWith {hint format ["%1 Vehicles Spawned",_vehCount];}

But no matter what I do with the semi-colons I always get an error saying I'm missing a ;

Share this post


Link to post
Share on other sites
On 8/29/2020 at 11:22 PM, Sld. Alexx Alvarez said:

Which was the problem? I'm interesting of this script

 

The other way to do this,  is to place 50 bikes on the map. Place them along a road in an out of the way place.

 

Then, when a trigger fires, one bike is moved to a random position    -  bike01   setpos   getpos  stone1 -  and ensure the stone starts at a place at random.

Do this with 50 triggers, 50 bikes and 50 stones.

.

  

Share this post


Link to post
Share on other sites
On 8/31/2020 at 1:42 AM, Joe98 said:

 

The other way to do this,  is to place 50 bikes on the map. Place them along a road in an out of the way place.

 

Then, when a trigger fires, one bike is moved to a random position    -  bike01   setpos   getpos  stone1 -  and ensure the stone starts at a place at random.

Do this with 50 triggers, 50 bikes and 50 stones.

.

  

Thanks You!!

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

×