Jump to content

Recommended Posts

Hello!

 

First | The basic premise of what I am attempting to do is two-fold. A) respawn existing vehicles (of different types - i.e. some jets, some helicopters, some ground vehicles), with the same custom pylons - for the jets/helis - set by the pylon/dynamic loadout editor in 3den. This part works fine thus far (see below). And B) apply unlimited ammo on a delay (i.e. it takes 45 seconds for the ammo to restore) to both the original vehicle and its respawned clone. The main trouble I am having is getting unlimited ammo to work with the new, respawned vehicles.

 

Second | A code dump and summary of what is where:

  • The code below is my unlimited ammo expression in the existing F/A-181 (and other vehicles). Ideally, the missiles & bombs refresh on a delay, hence the {sleep 45} segment. This part works perfectly for my purposes.
this addEventHandler ["Fired",{[_this select 0,getNumber (configFile/"CfgAmmo"/(_this select 4)/"explosive")] spawn {if (_this select 1==1) then {sleep 45};_this select 0 setVehicleAmmo 1}}];
  • This code is present in the expression of a Game Logic and synced to all relevant air vehicles. It works perfectly for my purposes; no errors and functions as intended.
[this] call {
	if (!isServer) exitWith {};
	params ["_thisObject"]; _vehs = synchronizedObjects _thisObject; _initScript = {
		params ["_vehicle", ["_pylons", "none"]];
		if (typeName _pylons == typeName []) then {
			private _pylonPaths = (configProperties [configFile >> "CfgVehicles" >> typeOf _vehicle >> "Components" >> "TransportPylonsComponent" >> "Pylons", "isClass _x"]) apply {
				getArray (_x >> "turret")
			};
			{
				_vehicle removeWeaponGlobal getText (configFile >> "CfgMagazines" >> _x >> "pylonWeapon")
			} forEach getPylonMagazines _vehicle;
			{
				_vehicle setPylonLoadout [_forEachIndex + 1, _x, true, _pylonPaths select _forEachIndex]
			} forEach _pylons;
		};
	};
	{
		[_x] call _initScript;
	} forEach _vehs;
	[_vehs, _initScript] spawn {
		params ["_vehs", "_initScript"];
		sleep 1; _respawnlist = []; {
			_respawnlist = _respawnlist + [[_x, position _x, [vectorDir _x, vectorUp _x], getPylonMagazines _x]]
		} forEach _vehs;
		while { true } do {
			sleep 1;
			{
				_veh = _x # 0;
				_respawnpos = _x # 1; _playerdistance = 200; {
					if (_veh distance _x < _playerdistance) then {
						_playerdistance = _veh distance _x
					};
				} forEach allPlayers;
				if (!alive _veh || (_veh distance _respawnpos > 20 && _playerdistance > 20)) then {
					_vehType = typeOf _veh;
					[_veh, _respawnlist] spawn {
						params ["_veh", "_respawnlist"];
						deleteVehicleCrew _veh; _veh lock true; _inSpawn = false; waitUntil {
							sleep 0.5;
							_inSpawn = false; {
								_respawnpos = _x # 1;
								if ((_veh distance _respawnpos) < 30) exitWith {
									_inSpawn = true;
								};
							} forEach _respawnlist;
							_inSpawn || ((speed _veh == 0) && (isTouchingGround _veh));
						};
						if (!_inSpawn) then {
							sleep 30
						};
						deleteVehicle _veh;
					};
					sleep 10; _newveh = _vehType createVehicle _respawnpos; _newveh setPos _respawnpos; _newveh setVectorDirAndUp (_x # 2);[_newveh, _x # 3] call _initScript; _respawnlist set [_forEachIndex, [_newveh, _respawnpos, _x # 2, _x # 3]];
				};
			} forEach _respawnlist;
		};
	};
};
  • This is the current code present in the "System Specific - Vehicle Respawn" Module expression (not its Init). It does not work at all.
params ["_newVeh", "_oldVeh"];
[_newVeh addEventHandler ["Fired", {
	[_newVeh select 0, getNumber (configFile/"CfgAmmo"/(_newVeh select 4)/"explosive")] spawn {
		if (_newVeh select 1 >= 0) then {
			sleep 5
		};
		_newVeh select 0 setVehicleAmmo 1
	}
}]] call BIS_fnc_initVehicle;

The Vehicle Respawn Module: ?imw=5000&imh=5000&ima=fit&impolicy=Lett

It throws the no errors upon mission launch and no errors upon vehicle respawn. My friends and I suspect it is not even executing properly.

 

  • Here are a few screencaps of the 3den editor of the scene in question if it helps you:

// Overview of the whole airfield. The Vehicle Respawn Module on the Right by the center of the airfiled is exlusively linked to ground vehicles. It respawns the vehicles fine but without the unlimited ammo.

?imw=5000&imh=5000&ima=fit&impolicy=Lett

// The test F/A-181.

?imw=5000&imh=5000&ima=fit&impolicy=Lett

// The Game Logic.

?imw=5000&imh=5000&ima=fit&impolicy=Lett

// My two primary test subjects (Left is experimental; Right is the control).

?imw=5000&imh=5000&ima=fit&impolicy=Lett

 

As you can see, the left F/A-181 is the primary test subject for the Vehicle Respawn Module, as it is synced to both the Vehicle Respawn and the Game Logic. The right F/A-181 (and all other air vehicles) is synced only to the Game Logic.

  • Both jets initially spawn with the proper pylons/dynamic loadouts and unlimited ammo, as expected vis-a-vis the 3den editor settings.
  • Both jets respawn with the proper pylons/dynamic loadouts.
  • Neither jet respawns with unlimited ammo, currently.

 

I feel close to solving this, but I am blind to what I am missing/adding unnecessarily.  I have tried numerous other variations with even less luck.

I am sure there is some redundancy between the Vehicle Respawn Module and the game logic, and I would appreciate any simplifications there. However, that is a secondary concern.

 

Thanks for reading this far! Hopefully, you can help me and anyone else who wants to do this.

Share this post


Link to post
Share on other sites
On 2/13/2024 at 2:02 AM, EveryEmpireFalls said:

This code is present in the expression of a Game Logic and synced to all relevant air vehicles.

I just browsed through it to clean it up a bit.

Spoiler

[ this ] call {
	params[ "_logic" ];
	
	if (!isServer) exitWith {};
	
	_vehs = synchronizedObjects _logic;
	
	_initPylons = {
		params[ "_vehicle", [ "_pylons", "none" ] ];
		
		//If _pylons is an ARRAY
		if ( _pylons isEqualType [] ) then {
			private _pylonPaths = configProperties[ configFile >> "CfgVehicles" >> typeOf _vehicle >> "Components" >> "TransportPylonsComponent" >> "Pylons", "isClass _x" ] apply {
				getArray ( _x >> "turret" )
			};
			{
				_vehicle removeWeaponGlobal getText (configFile >> "CfgMagazines" >> _x >> "pylonWeapon")
			}forEach getPylonMagazines _vehicle;
			{
				_vehicle setPylonLoadout [_forEachIndex + 1, _x, true, _pylonPaths select _forEachIndex]
			}forEach _pylons;
		};
	};
	
	{
		[ _x ] call _initPylons;
	}forEach _vehs;
	
	[ _vehs, _initPylons ] spawn {
		params[ "_vehs", "_initPylons" ];
		
		//Make respawn data structure from passed vehicles
		private _respawnList = _vehs apply{ [ _x, getPosATL _x, [ vectorDir _x, vectorUp _x ], getPylonMagazines _x ] };
			
		while { true } do {
			
			sleep 10;
			
			private _respawnDistance = 20;
			private _respawnDistanceSqr = _respawnDistance ^2;	//distance( 20m ) squared( ^2 ) as we are going to use distanceSqr commands as it is computationally lighter
					
			{
				//Might aswell just extract data info here from _x
				_x params[ "_veh", "_respawnPos", "_vecDirAndUp", "_pylonMags" ];
				
				//Vehicle is not alive OR its further away from _respawnPos than _respawnDistanceSqr
				if ( !alive _veh || { _veh distanceSqr _respawnPos > _respawnDistanceSqr } ) then {
	
					//Only check players now once we know vehicle could possibly respawn( dead OR too far from _respawnPos )
					//to save computing player distances if not needed
					//Get any alive players within _respawnDistanceSqr of the vehicle
					private _nearPlayers = allPlayers select{ alive _x && { _x distanceSqr _veh <= _respawnDistanceSqr } };
					
					//vehicle has nearby players( within _respawnDistanceSqr ) 
					if ( count _nearPlayers > 0 ) then {
						//Goto next vehicle in _respawnList
						continue;
					};
	
					//Why do the _inSpawn check?,
					//You immediately deleted any crew and locked the vehicle so there is no chance of it going anywhere anyway so not needed
					//And if its possibly being transported its going to have a near player anyway
	
					_veh lock true;
					deleteVehicleCrew _veh;	//May want to delete any crew groups that are now empty, unless handled else where by deleteGroupWhenEmpty
					
					//Spawn new vehicle	
					//spawn at corner of map in the air so we can set its rotation before placing it
					private _newVeh = createVehicle[ typeOf _veh, [0, 0, 100], [], 0, "NONE" ];
					_newveh setVectorDirAndUp _vecDirAndUp;
					//Now move it to _respawnPos
					_newveh setPosATL _respawnPos;
					
					//Spawn, lets get on with checking the next vehicle
					[ _newveh, _pylonMags ] spawn _initPylons;
										
					//Update data structure
					_respawnlist set[ _forEachIndex, [ _newveh, _respawnPos, _vecDirAndUp, _pylonMags ] ];
					
					//Delete previous vehicle
					deleteVehicle _veh;
				};
				
			} forEach _respawnlist;
		};
	};
	
};

 

 

On 2/13/2024 at 2:02 AM, EveryEmpireFalls said:

This is the current code present in the "System Specific - Vehicle Respawn" Module expression (not its Init). It does not work at all.

I don't understand why you have the EH contained within a BIS_fnc_initVehicle. It should just be...

Spoiler

params[ "_newVeh", "_oldVeh" ];

_newVeh addEventHandler[ "Fired", {
	_this spawn {
		params[ "_vehicle", "", "", "", "_ammo" ];
		
		if !( _vehicle getVariable[ "awaitingAmmo", false ] ) then {
			if ( getNumber( configFile >> "CfgAmmo" >> _ammo >> "explosive" ) > 0 ) then {
				_vehicle setVariable[ "awaitingAmmo", true ];
				sleep 5;
				_vehicle setVariable[ "awaitingAmmo", false ];
			};
		
			_vehicle setVehicleAmmo 1;
		};
	};
}];

 

Added in a check to ensure the event code is not already sleeping due to explosive ammo having been used previously, so as not to queue up loads of setVehicleAmmo commands in the scheduler if someone is spam firing explosives. The only detriment this will have is if someone has fired explosive ammo and then unleashes lots of projectiles( machine guns etc ) then those won't refill until explosives refill, but it's only five seconds so not really a bother, better than the possibility of suddenly having setVehicleAmmo spam over and over again.

 

All are untested and you will likely need to remove the comments depending on where you are pasting these scripts. Hope it helps.

  • Like 1

Share this post


Link to post
Share on other sites
2 hours ago, Larrow said:

I just browsed through it to clean it up a bit.

  Reveal hidden contents


[ this ] call {
	params[ "_logic" ];
	
	if (!isServer) exitWith {};
	
	_vehs = synchronizedObjects _logic;
	
	_initPylons = {
		params[ "_vehicle", [ "_pylons", "none" ] ];
		
		//If _pylons is an ARRAY
		if ( _pylons isEqualType [] ) then {
			private _pylonPaths = configProperties[ configFile >> "CfgVehicles" >> typeOf _vehicle >> "Components" >> "TransportPylonsComponent" >> "Pylons", "isClass _x" ] apply {
				getArray ( _x >> "turret" )
			};
			{
				_vehicle removeWeaponGlobal getText (configFile >> "CfgMagazines" >> _x >> "pylonWeapon")
			}forEach getPylonMagazines _vehicle;
			{
				_vehicle setPylonLoadout [_forEachIndex + 1, _x, true, _pylonPaths select _forEachIndex]
			}forEach _pylons;
		};
	};
	
	{
		[ _x ] call _initPylons;
	}forEach _vehs;
	
	[ _vehs, _initPylons ] spawn {
		params[ "_vehs", "_initPylons" ];
		
		//Make respawn data structure from passed vehicles
		private _respawnList = _vehs apply{ [ _x, getPosATL _x, [ vectorDir _x, vectorUp _x ], getPylonMagazines _x ] };
			
		while { true } do {
			
			sleep 10;
			
			private _respawnDistance = 20;
			private _respawnDistanceSqr = _respawnDistance ^2;	//distance( 20m ) squared( ^2 ) as we are going to use distanceSqr commands as it is computationally lighter
					
			{
				//Might aswell just extract data info here from _x
				_x params[ "_veh", "_respawnPos", "_vecDirAndUp", "pylonMags" ];
				
				//Vehicle is not alive OR its further away from _respawnPos than _respawnDistanceSqr
				if ( !alive _veh || { _veh distanceSqr _respawnPos > _respawnDistanceSqr } ) then {
	
					//Only check players now once we know vehicle could possibly respawn( dead OR too far from _respawnPos )
					//to save computing player distances if not needed
					//Get any alive players within _respawnDistanceSqr of the vehicle
					private _nearPlayers = allPlayers select{ alive _x && { _x distanceSqr _veh <= _respawnDistanceSqr } };
					
					//vehicle has nearby players( within _respawnDistanceSqr ) 
					if ( count _nearPlayers > 0 ) then {
						//Goto next vehicle in _respawnList
						continue;
					};
	
					//Why do the _inSpawn check?,
					//You immediately deleted any crew and locked the vehicle so there is no chance of it going anywhere anyway so not needed
					//And if its possibly being transported its going to have a near player anyway
	
					_veh lock true;
					deleteVehicleCrew _veh;	//May want to delete any crew groups that are now empty, unless handled else where by deleteGroupWhenEmpty
					
					//Spawn new vehicle	
					//spawn at corner of map in the air so we can set its rotation before placing it
					private _newVeh = createVehicle[ typeOf _veh, [0, 0, 100], [], 0, "NONE" ];
					_newveh setVectorDirAndUp _vecDirAndUp;
					//Now move it to _respawnPos
					_newveh setPosATL _respawnPos;
					
					//Spawn, lets get on with checking the next vehicle
					[ _newveh, _pylonPaths ] spawn _initPylons;
										
					//Update data structure
					_respawnlist set[ _forEachIndex, [ _newveh, _respawnPos, _vecDirAndUp, _pylonMags ] ];
					
					//Delete previous vehicle
					deleteVehicle _veh;
				};
				
			} forEach _respawnlist;
		};
	};
	
};

 

 

I don't understand why you have the EH contained within a BIS_fnc_initVehicle. It should just be...

 Reveal hidden contents Reveal hidden contents


params[ "_newVeh", "_oldVeh" ];

_newVeh addEventHandler[ "Fired", {
	_this spawn {
		params[ "_vehicle", "", "", "", "_ammo" ];
		
		if !( _vehicle getVariable[ "awaitingAmmo", false ] ) then {
			if ( getNumber( configFile >> "CfgAmmo" >> _ammo >> "explosive" ) > 0 ) then {
				_vehicle setVariable[ "awaitingAmmo", true ];
				sleep 5;
				_vehicle setVariable[ "awaitingAmmo", false ];
			};
		
			_vehicle setVehicleAmmo 1;
		};
	};
}];

 

Added in a check to ensure the event code is not already sleeping due to explosive ammo having been used previously, so as not to queue up loads of setVehicleAmmo commands in the scheduler if someone is spam firing explosives. The only detriment this will have is if someone has fired explosive ammo and then unleashes lots of projectiles( machine guns etc ) then those won't refill until explosives refill, but it's only five seconds so not really a bother, better than the possibility of suddenly having setVehicleAmmo spam over and over again.

 

All are untested and you will likely need to remove the comments depending on where you are pasting these scripts. Hope it helps.

Thanks for the reply, Larrow.

 

I took your code snippet for the Vehicle Respawn unlimited ammo and placed it in the expression field of said module; it works great!

 

However, I do not completely follow what you do with the pylons in your cleaned-up code (even with the help of a friend more experienced with Arma language than I). Additionally, it throws some errors:

  • "Error local variable in global space" around this line.
_x params[ "_veh", "_respawnPos", "_vecDirAndUp", "pylonMags" ];
  • pylonMags appears to be the fault here, as it is not local. We corrected the pylonMags to _pylonMags, which solved that issue.
  • However, now it throws an "error undefined variable in expression _pylonPaths".

Thanks again for your assistance.

Share this post


Link to post
Share on other sites
22 hours ago, EveryEmpireFalls said:
  • "Error local variable in global space" around this line.

_x params[ "_veh", "_respawnPos", "_vecDirAndUp", "pylonMags" ];
  • pylonMags appears to be the fault here, as it is not local. We corrected the pylonMags to _pylonMags, which solved that issue.

Opps yep you caught this one, its just missing the local underscore.

 

22 hours ago, EveryEmpireFalls said:

However, now it throws an "error undefined variable in expression _pylonPaths". 

This should be the same variable _pylonMags instead, its your original _x#3 from the _respawnList( getPylonMagazines ) data structure.

 

Fix both of these errors in my previous post.

  • Like 1

Share this post


Link to post
Share on other sites
On 2/15/2024 at 8:42 PM, Larrow said:

Opps yep you caught this one, its just missing the local underscore.

 

This should be the same variable _pylonMags instead, its your original _x#3 from the _respawnList( getPylonMagazines ) data structure.

 

Fix both of these errors in my previous post.

I think I miscommunicated with you in my previous response (my bad).

 

The "Error undefined variable in expression _pylonPaths" was thrown around here:

297a14449dd844ce09a4a5b5d3de93e8.png

 

I did edit the pylonMags -> _pylonMags, and that portion appears to work fine.

 

We tried the https://community.bistudio.com/wiki/Arma_3:_Vehicle_Loadouts "Saving and Restoring" segment by manually hardcoding the pylon loadouts and that worked but appears to have overwritten the unlimited ammo execution.

 

Just for clarity's sake I have copied the current code below:

[ this ] call {
	params[ "_logic" ];

	if (!isServer) exitWith {};

	_vehs = synchronizedObjects _logic;

	_initPylons = {
		params[ "_vehicle", [ "_pylons", "none" ] ];

		if (_pylons isEqualType []) then {
			private _pylonPaths = configProperties[ configFile >> "CfgVehicles" >> typeOf _vehicle >> "Components" >> "TransportPylonsComponent" >> "Pylons", "isClass _x" ] apply {
				getArray (_x >> "turret")
			};
			{
				_vehicle removeWeaponGlobal getText (configFile >> "CfgMagazines" >> _x >> "pylonWeapon")
			}forEach getPylonMagazines _vehicle;
			{
				_vehicle setPylonLoadout [_forEachIndex + 1, _x, true, _pylonPaths select _forEachIndex]
			}forEach _pylons;
		};
	};

	{
		[ _x ] call _initPylons;
	}forEach _vehs;

	[ _vehs, _initPylons ] spawn {
		params[ "_vehs", "_initPylons" ];

		private _respawnList = _vehs apply{
			[ _x, getPosATL _x, [ vectorDir _x, vectorUp _x ], getPylonMagazines _x ]
		};

		while { true } do {
			sleep 10;

			private _respawnDistance = 20;
			private _respawnDistanceSqr = _respawnDistance ^2;

			{
				_x params[ "_veh", "_respawnPos", "_vecDirAndUp", "_pylonMags" ];

				if ( !alive _veh || {
					_veh distanceSqr _respawnPos > _respawnDistanceSqr
				} ) then {
					private _nearPlayers = allPlayers select{
						alive _x && {
							_x distanceSqr _veh <= _respawnDistanceSqr
						}
					};

					if (count _nearPlayers > 0) then {
						continue;
					};

					_veh lock true;
					deleteVehicleCrew _veh;

					private _newVeh = createVehicle[ typeOf _veh, [0, 0, 100], [], 0, "NONE" ];
					_newveh setVectorDirAndUp _vecDirAndUp;
					_newveh setPosATL _respawnPos;

					[ _newveh, _pylonMags ] spawn _initPylons;

					_respawnlist set[ _forEachIndex, [ _newveh, _respawnPos, _vecDirAndUp, _pylonMags ] ];

					deleteVehicle _veh;
				};
			} forEach _respawnlist;
		};
	};
};

 

And further, here is the hardcoded version with ONLY the F/A-181's loadouts (which is less than ideal because we want it to work for multiple types of vehicles without having to manually load each):

[ this ] call {
	params[ "_logic" ];

	if (!isServer) exitWith {};

	_vehs = synchronizedObjects _logic;

	_initPylons = {
		params[ "_vehicle", [ "_pylons", "none" ] ];
		private _pylons = ["PylonRack_Missile_AGM_02_x1", "PylonRack_Missile_AGM_02_x1", "PylonRack_Missile_HARM_x1", "PylonRack_Missile_HARM_x1", "PylonMissile_Missile_BIM9X_x1", "PylonMissile_Missile_BIM9X_x1", "PylonMissile_Missile_AMRAAM_D_INT_x1", "PylonMissile_Missile_AMRAAM_D_INT_x1", "PylonRack_Bomb_SDB_x4", "PylonRack_Bomb_SDB_x4", "PylonMissile_1Rnd_BombCluster_01_F", "PylonMissile_1Rnd_BombCluster_01_F"];
		if (_pylons isEqualType []) then {
			private _pylonPaths = configProperties[ configFile >> "CfgVehicles" >> typeOf _vehicle >> "Components" >> "TransportPylonsComponent" >> "Pylons", "isClass _x" ] apply {
				getArray (_x >> "turret")
			};
			{
				_vehicle removeWeaponGlobal getText (configFile >> "CfgMagazines" >> _x >> "pylonWeapon")
			}forEach getPylonMagazines _vehicle;
			{
				_vehicle setPylonLoadout [_forEachIndex + 1, _x, true, _pylonPaths select _forEachIndex]
			}forEach _pylons;
		};
	};

	{
		[ _x ] call _initPylons;
	}forEach _vehs;

	[ _vehs, _initPylons ] spawn {
		params[ "_vehs", "_initPylons" ];

		private _respawnList = _vehs apply{
			[ _x, getPosATL _x, [ vectorDir _x, vectorUp _x ], getPylonMagazines _x ]
		};

		while { true } do {
			sleep 10;

			private _respawnDistance = 20;
			private _respawnDistanceSqr = _respawnDistance ^2;

			{
				_x params[ "_veh", "_respawnPos", "_vecDirAndUp", "_pylonMags" ];

				if ( !alive _veh || {
					_veh distanceSqr _respawnPos > _respawnDistanceSqr
				} ) then {
					private _nearPlayers = allPlayers select{
						alive _x && {
							_x distanceSqr _veh <= _respawnDistanceSqr
						}
					};

					if (count _nearPlayers > 0) then {
						continue;
					};

					_veh lock true;
					deleteVehicleCrew _veh;

					private _newVeh = createVehicle[ typeOf _veh, [0, 0, 100], [], 0, "NONE" ];
					_newveh setVectorDirAndUp _vecDirAndUp;
					_newveh setPosATL _respawnPos;

					[ _newveh, _pylonMags ] spawn _initPylons;

					_respawnlist set[ _forEachIndex, [ _newveh, _respawnPos, _vecDirAndUp, _pylonMags ] ];

					deleteVehicle _veh;
				};
			} forEach _respawnlist;
		};
	};
};

 

Share this post


Link to post
Share on other sites

We tried doing the _pylonPaths before the if/then loop as seen here:

[ this ] call {
    params[ "_logic" ];

    if (!isServer) exitWith {};

    _vehs = synchronizedObjects _logic;

    _initPylons = {
        params[ "_vehicle", [ "_pylons", "none" ] ];
                private "_pylonPaths";
        if (_pylons isEqualType []) then {
            _pylonPaths = configProperties[ configFile >> "CfgVehicles" >> typeOf _vehicle >> "Components" >> "TransportPylonsComponent" >> "Pylons", "isClass _x" ] apply {
                getArray (_x >> "turret")
            };
            {
                _vehicle removeWeaponGlobal getText (configFile >> "CfgMagazines" >> _x >> "pylonWeapon")
            }forEach getPylonMagazines _vehicle;
            {
                _vehicle setPylonLoadout [_forEachIndex + 1, _x, true, _pylonPaths select _forEachIndex]
            }forEach _pylons;
        };
    };

    {
        [ _x ] call _initPylons;
    }forEach _vehs;

    [ _vehs, _initPylons ] spawn {
        params[ "_vehs", "_initPylons" ];

        private _respawnList = _vehs apply{
            [ _x, getPosATL _x, [ vectorDir _x, vectorUp _x ], getPylonMagazines _x ]
        };

        while { true } do {
            sleep 10;

            private _respawnDistance = 20;
            private _respawnDistanceSqr = _respawnDistance ^2;

            {
                _x params[ "_veh", "_respawnPos", "_vecDirAndUp", "_pylonMags" ];

                if ( !alive _veh || {
                    _veh distanceSqr _respawnPos > _respawnDistanceSqr
                } ) then {
                    private _nearPlayers = allPlayers select{
                        alive _x && {
                            _x distanceSqr _veh <= _respawnDistanceSqr
                        }
                    };

                    if (count _nearPlayers > 0) then {
                        continue;
                    };

                    _veh lock true;
                    deleteVehicleCrew _veh;

                    private _newVeh = createVehicle[ typeOf _veh, [0, 0, 100], [], 0, "NONE" ];
                    _newveh setVectorDirAndUp _vecDirAndUp;
                    _newveh setPosATL _respawnPos;

                    [ _newveh, _pylonMags ] spawn _initPylons;

                    _respawnlist set[ _forEachIndex, [ _newveh, _respawnPos, _vecDirAndUp, _pylonMags ] ];

                    deleteVehicle _veh;
                };
            } forEach _respawnlist;
        };
    };
};

With no luck.

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

×