Jump to content
Sign in to follow this  
Ice_Rhino

Repeat Spawning Vehicles

Recommended Posts

I wish to learn how to spawn vehicles at a given time anyway, but for now I just need to know how to, or if it is possible, to spawn 2 OPFOR & 2 BLUFOR every 5 mins at specific locations, then every 4 minutes I will de-spawn if they are still alive.

Anybody able to help me out here?

Thanks in advance

Share this post


Link to post
Share on other sites

be more precise!

one solution(removes vehicle after 5 minutes if it can not move anylonger or no driver was in in this time and respawns it):

CODI_fort_fnc_initVehicleRespawn =
{
_vehicle = _this select 0;
_pos = _this select 1;
_inUse = true;
waitUntil {!isNull (driver _vehicle) || !canMove _vehicle};
_timeUnused = 0;
while {_inUse} do
{
	if (isNull (driver _vehicle) || !canMove _vehicle) then
	{
		_timeUnused = _timeUnused + 1;
	};
	if (!isNull (driver _vehicle) && canMove _vehicle) then
	{
		_timeUnused = 0;
	};
	if (_timeUnused == 300) then
	{
		_inUse = false;
	};
	sleep 1;
};
_type = typeOf _vehicle;
deleteVehicle _vehicle;
sleep 1;
_newVehicle = createVehicle [_type, _pos, [], 0, "CAN_COLLIDE"];
[_newVehicle, _pos] spawn CODI_fort_fnc_initVehicleRespawn;
};

usage:

_null = [this, getPos this] spawn CODI_fort_fnc_initVehicleRespawn;

Edited by Coding

Share this post


Link to post
Share on other sites

Precise, OK, I will try.

I have my mission where you start as part of an armoured column, eventually you get into a armour v armour battle outside of the small town of Zaros on ALTIS. At some point you will be forced to leave your armour and proceed into the town on foot. What I was trying to achieve was the continuation of an armour battle out in the approach or surrounding outer areas of the town. Sort of like clearing inside while it is all kicking off outside the town. Setting the ambience of a serious armour exchange battle, tracer fire, missiles, the whole shebang.

Is that better?

Apologies if I was lame on my first description

Share this post


Link to post
Share on other sites

ok, I think I understand your missionbehaviour but with detail i meant the respawnbehaviour...

the above script shall do the job.

to decrease the respawn time edit:

if (_timeUnused == 300) then

to: (for example 2 minutes)

if (_timeUnused == 120) then

Share this post


Link to post
Share on other sites

Thanks, I am trying to understand the code you have provided. in terms of respawn. On a trigger I would like to spawn two armour units from each side at certain locations. They can duke it out for however long, then after 4 minutes despawn them if they are still alive, then 1 minute after that, respawn them and the cycle begins again.

Any clearer?

Share this post


Link to post
Share on other sites

ok,

in trigger do something like

_veh1 = createVehicle [...];//must be edited
_veh2 = createVehicle [...];//must be edited
[veh1] spawn YOURRESPAWNFUNCTION;
[veh2] spawn YOURRESPAWNFUNCTION;

in init.sqf:

YOURRESPAWNFUNCTION =
{
 _veh = _this select 0;
 sleep (4*60);
 deleteVehicle _veh;
 sleep (1*60);
 _newVeh = createVehicle[typeOf _veh, getMarkerPos "YOURRESPAWNMARKER", ["YOURRESPAWNMARKER2", "YOURRESPAWNMARKER3", ...], 0, "NONE"];//must be edited
 [_newVeh] spawn YOURRESPAWNFUNCTION;
};//here was a ; missing... :D

and place a marker called YOURRESPAWNMARKER (1,2,3,...) where you want the vehicles to respawn

this have to be done for both teams

you need one RESPAWNFUNCTION for blu and one for opfor because they shall use different markers I think

Edited by Coding

Share this post


Link to post
Share on other sites

Thank you for keeping up with this thread 'coding'. I understand what you have put I just need to learn the YOURRESPAWNFUNCTION bit etc

My sincerest thanks

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  

×