Jump to content
Sign in to follow this  
nebulazerz

Checking 3 Markers for objects and not allowing if all are full.

Recommended Posts

I am working on my vehicle shop and I am trying to make it so vehicles can be spawned in 3 random spots but cant be spawned if all 3 spots are full. I have this working fine for one marker but its telling me that _nearestTargetsB is undefined. this is what I have.

disableSerialization;
		private["_positionA","_positionB","_positionC","_direction","_nearestTargetsA","_nearestTargetsB","_nearestTargetsC","_nearestTargetsAll","_scanArea"];
//Create Markers
		createMarker ["BluVehASpawnA",[3124.154,13062.615]];
		"BluVehASpawnA" setMarkerType "Empty";
		"BluVehASpawnA" setMarkerSize [2, 2];
		
		createMarker ["BluVehASpawnB",[3123.914,13051.089]];
		"BluVehASpawnB" setMarkerType "Empty";
		"BluVehASpawnB" setMarkerSize [2, 2];
		
		createMarker ["BluVehASpawnC",[3122.714,13039.563]];
		"BluVehASpawnC" setMarkerType "Empty";
		"BluVehASpawnC" setMarkerSize [2, 2];
//Check if the marker has any cars near it
		_positionA = getMarkerPos "BluVehASpawnA";
		_positionB = getMarkerPos "BluVehASpawnB";
		_positionC = getMarkerPos "BluVehASpawnC";
		_scanArea = 5;
		_direction = 85;
		_nearestTargetsA = nearestObjects[_positionA,["landVehicle","Air","Ship"],_scanArea] select 0;
		_nearestTargetsB = nearestObjects[_positionB,["landVehicle","Air","Ship"],_scanArea] select 0;
		_nearestTargetsC = nearestObjects[_positionC,["landVehicle","Air","Ship"],_scanArea] select 0;
		_nearestTargetsAll = (_nearestTargetsA + _nearestTargetsB + _nearestTargetsC);
//if the marker has no cars near it then spawn the new car with nothing in inventory
if (!isNil "_nearestTargetsAll") then {
			hint " ALL MATERIALIZATION PADS FULL ";
		}else{
				_veh = createVehicle ["B_T_LSV_01_unarmed_F", getMarkerPos "BluVehASpawnA", ["BluVehASpawnB","BluVehASpawnC"], 0, "NONE"];
				_veh setVariable ["BIS_enableRandomization", false];
				_veh setDir _direction;
				_veh setPos _position;
				clearWeaponCargoGlobal _veh;
				clearMagazineCargoGlobal _veh;
				clearItemCargoGlobal _veh;
				deleteMarker "BluVehASpawnA";
				
		};

Share this post


Link to post
Share on other sites

Pls post the error u get from .rpt file

9:53:19 Starting mission:
 9:53:19  Mission file: BaseWars
 9:53:19  Mission world: Tanoa
 9:53:19  Mission directory: C:\Users\Nebulazer\Documents\Arma 3 - Other Profiles\Nebulazerz\mpmissions\BaseWars.Tanoa\
 9:53:20 Attempt to override final function - bis_functions_list
 9:53:20 Attempt to override final function - bis_functions_listpreinit
 9:53:20 Attempt to override final function - bis_functions_listpostinit
 9:53:20 Attempt to override final function - bis_functions_listrecompile
 9:53:20 Attempt to override final function - bis_fnc_missiontaskslocal
 9:53:20 Attempt to override final function - bis_fnc_missionconversationslocal
 9:53:20 Attempt to override final function - bis_fnc_missionflow
 9:53:21 No speaker given for Gao Ong
 9:53:21 No speaker given for Gao Choy
 9:53:22 c:\w\dev\futura\lib\network\networkserver.cpp NetworkServer::OnClientStateChanged:NOT IMPLEMENTED - briefing!
 9:53:24 A nil object passed as a target to RemoteExec(Call) 'bis_fnc_shownotification'
 9:53:24 A nil object passed as a target to RemoteExec(Call) 'bis_fnc_shownotification'
 9:53:26 Save game type
 9:54:07 Error in expression <canArea] select 0;
_nearestTargetsAll = _nearestTargetsA + _nearestTargetsB + _n>
 9:54:07   Error position: <_nearestTargetsA + _nearestTargetsB + _n>
 9:54:07   Error Undefined variable in expression: _nearesttargetsa
 9:54:07 File C:\Users\Nebulazer\Documents\Arma 3 - Other Profiles\Nebulazerz\mpmissions\BaseWars.Tanoa\Classes\Blu\Vehicles\Prowler\prowlerSpawn.sqf, line 26
 9:54:07 Error in expression <e];
_veh setDir _direction;
_veh setPos _position;
clearWeaponCargoGlobal _veh;
>
 9:54:07   Error position: <_position;
clearWeaponCargoGlobal _veh;
>
 9:54:07   Error Undefined variable in expression: _position
 9:54:07 File C:\Users\Nebulazer\Documents\Arma 3 - Other Profiles\Nebulazerz\mpmissions\BaseWars.Tanoa\Classes\Blu\Vehicles\Prowler\prowlerSpawn.sqf, line 34
 9:55:04 Error in expression <_nearestTargetsAll = _nearestTargetsA + _nearestTargetsB + _nearestTargetsC;

if>
 9:55:04   Error position: <_nearestTargetsB + _nearestTargetsC;

if>
 9:55:04   Error +: Undefined variable in expression: _nearesttargetsb
 9:55:04 File C:\Users\Nebulazer\Documents\Arma 3 - Other Profiles\Nebulazerz\mpmissions\BaseWars.Tanoa\Classes\Blu\Vehicles\Prowler\prowlerSpawn.sqf, line 26
 9:55:36 Error in expression <_nearestTargetsAll = _nearestTargetsA + _nearestTargetsB + _nearestTargetsC;

if>
 9:55:36   Error position: <_nearestTargetsB + _nearestTargetsC;

if>
 9:55:36   Error +: Undefined variable in expression: _nearesttargetsb
 9:55:36 File C:\Users\Nebulazer\Documents\Arma 3 - Other Profiles\Nebulazerz\mpmissions\BaseWars.Tanoa\Classes\Blu\Vehicles\Prowler\prowlerSpawn.sqf, line 26
 9:56:37 Error in expression <nearestTargetsAll = (_nearestTargetsA + _nearestTargetsB + _nearestTargetsC);

i>
 9:56:37   Error position: <_nearestTargetsB + _nearestTargetsC);

i>
 9:56:37   Error +: Undefined variable in expression: _nearesttargetsb
 9:56:37 File C:\Users\Nebulazer\Documents\Arma 3 - Other Profiles\Nebulazerz\mpmissions\BaseWars.Tanoa\Classes\Blu\Vehicles\Prowler\prowlerSpawn.sqf, line 26
 9:56:48 Error in expression <nearestTargetsAll = (_nearestTargetsA + _nearestTargetsB + _nearestTargetsC);

i>
 9:56:48   Error position: <_nearestTargetsB + _nearestTargetsC);

i>
 9:56:48   Error +: Undefined variable in expression: _nearesttargetsb
 9:56:48 File C:\Users\Nebulazer\Documents\Arma 3 - Other Profiles\Nebulazerz\mpmissions\BaseWars.Tanoa\Classes\Blu\Vehicles\Prowler\prowlerSpawn.sqf, line 26

Share this post


Link to post
Share on other sites

Pls post the error u get from .rpt file

Nvm got it to work, sorry was having a brain fart and was a simple solution, I should have just thought over it more but was in a rush to go to work earlier. Here is the working version feel free to use it, should be able to be used for how ever many markers you want to use which fixes the problem of vehicles spawning where they want and exploding.

 

EDIT: this seems to work best though it still allows a 4th vehicle to spawn within 3 markers that are spread out decently but shows the area as full after 4th. I might be doing something weird in the detection process that someone can fix to make it more accurate but it does work for what i need for now.

 

E09269DE2C4FBC3073EEEBA2B6292C30CFAAB417

		disableSerialization;
		private["_positionA","_positionB","_positionC","_direction","_nearestTargetsA","_nearestTargetsB","_nearestTargetsC","_nearestTargetsAll","_scanArea"];
//Create Markers
		createMarker ["BluVehASpawnA",[3133.280,13062.375]];
		"BluVehASpawnA" setMarkerType "Empty";
		"BluVehASpawnA" setMarkerSize [2, 2];
		
		createMarker ["BluVehASpawnB",[3127.516,13036.2]];
		"BluVehASpawnB" setMarkerType "Empty";
		"BluVehASpawnB" setMarkerSize [2, 2];
		
		createMarker ["BluVehASpawnC",[3139.763,13091.672]];
		"BluVehASpawnC" setMarkerType "Empty";
		"BluVehASpawnC" setMarkerSize [2, 2];
//Check if the marker has any cars near it
		_positionA = getMarkerPos "BluVehASpawnA";
		_positionB = getMarkerPos "BluVehASpawnB";
		_positionC = getMarkerPos "BluVehASpawnC";
		_scanArea = 10;
		_direction = 210;
		_nearestTargetsA = nearestObjects[_positionA,["landVehicle","Air","Ship"],_scanArea] select 0;
		_nearestTargetsB = nearestObjects[_positionB,["landVehicle","Air","Ship"],_scanArea] select 0;
		_nearestTargetsC = nearestObjects[_positionC,["landVehicle","Air","Ship"],_scanArea] select 0;
//if the marker has no cars near it then spawn the new car with nothing in inventory
		if ((!isNil "_nearestTargetsA") and (!isNil "_nearestTargetsB") && (!isNil "_nearestTargetsC") ) then {
			hint " MATERIALIZATION AREA FULL ";
		}else{
				_veh = createVehicle ["B_T_LSV_01_unarmed_F", getMarkerPos "BluVehASpawnA", ["BluVehASpawnB","BluVehASpawnC"], 0, "NONE"];
				_veh setVariable ["BIS_enableRandomization", false];
				_veh setDir _direction;
				clearWeaponCargoGlobal _veh;
				clearMagazineCargoGlobal _veh;
				clearItemCargoGlobal _veh;
				deleteMarker "BluVehASpawnA";
				
		};

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  

×