Jump to content
Sign in to follow this  
_qor

"forEach vehicles thislist" doesnt work?

Recommended Posts

Hey,

I want to add an action for each vehicle which is in the list of a trigger. So I would use this code:

{_x addAction ["LOAD VEHICLE","Support\constructions.sqf","ConStru",1,false,false,"","((_target distance _this) <6)"]} forEach vehicles thislist

Unfortunately this is not possible. But I dont know what might be wrong with "forEach vehicles thislist".

In other cases I already noticed that referring to vehicles in triggers is kinda impossible. Hope you can help out!

Thanks in advance!

Share this post


Link to post
Share on other sites

Maybe something like this,obviously if you want planes and boat then you will need you would nedd to modify it a little.

{if (_x iskindof "landvehicle") then {_x addAction ["LOAD VEHICLE","Support\constructions.sqf","ConStru",1,false,false,"","((_target distance _this) <6)"]}} forEach  thislist

not test but it should be close, also you don't say if they will have a crew or not.

If they are empty then it won't work you'll need to uses nearestobjects.

Share this post


Link to post
Share on other sites

Unfortunately this also adds the action to all vehicles and units ._.

I just want to have a trigger area which adds an action to only all vehicles inside when certain conditions are true.

And of course it should delete this action when the conditions are false.

So how to choose only vehicles in the list of a trigger? Shouldn't this work with list ?

Edited by _qoR

Share this post


Link to post
Share on other sites

Try this.

I'm currently having a similar problem with a simple forEach allUnits; command:

while {true} do 
{
	sleep 5;
	{
       if (side _x == west) then  
		{ 
			if ((paramsarray select 9) == 1 OR (paramsarray select 12) == 1) then {
					_x unlinkItem "NVGoggles";
					_x unlinkItem "NVGoggles_OPFOR";
					_x unlinkItem "NVGoggles_INDEP";
					_x removePrimaryWeaponItem "acc_pointer_IR";
					_x addPrimaryWeaponItem "acc_flashlight";
					_x enablegunlights "forceOn";
				};
			if (isnil "master") then {} else {
					master addCuratorEditableObjects [[_x],true];
				};
			if (isnil "master_1") then {} else {
					master_1 addCuratorEditableObjects [[_x],true];
				};
		};
	if (side _x == east) then  
		{ 
			if ((paramsarray select 10) == 1 OR (paramsarray select 12) == 1) then {
					_x unlinkItem "NVGoggles";
					_x unlinkItem "NVGoggles_OPFOR";
					_x unlinkItem "NVGoggles_INDEP";
					_x removePrimaryWeaponItem "acc_pointer_IR";
					_x addPrimaryWeaponItem "acc_flashlight";
					_x enablegunlights "forceOn";
				};
			if (isnil "master") then {} else {
					master addCuratorEditableObjects [[_x],true];
				};
			if (isnil "master_1") then {} else {
					master_1 addCuratorEditableObjects [[_x],true];
				};
		};
	if (side _x == independent) then  
		{ 
			if ((paramsarray select 11) == 1 OR (paramsarray select 12) == 1) then {
					_x unlinkItem "NVGoggles";
					_x unlinkItem "NVGoggles_OPFOR";
					_x unlinkItem "NVGoggles_INDEP";
					_x removePrimaryWeaponItem "acc_pointer_IR";
					_x addPrimaryWeaponItem "acc_flashlight";
					_x enablegunlights "forceOn";
				};
			if (isnil "master") then {} else {
					master addCuratorEditableObjects [[_x],true];
				};
			if (isnil "master_1") then {} else {
					master_1 addCuratorEditableObjects [[_x],true];
				};
		};
	if (side _x == civilian) then  
		{ 
			if ((paramsarray select 12) == 1) then {
					_x unlinkItem "NVGoggles";
					_x unlinkItem "NVGoggles_OPFOR";
					_x unlinkItem "NVGoggles_INDEP";
					_x removePrimaryWeaponItem "acc_pointer_IR";
					_x addPrimaryWeaponItem "acc_flashlight";
					_x enablegunlights "forceOn";
				};
			if ((paramsarray select 15) == 1) then {
				if (isnil "master") then {} else {
						master addCuratorEditableObjects [[_x],true];
					};
			if (isnil "master_1") then {} else {
					master_1 addCuratorEditableObjects [[_x],true];
				};
			};
		};
	if (side _x == sideEnemy) then  
		{ 
			if (isServer && (paramsarray select 12) == 1) then {
					_x unlinkItem "NVGoggles";
					_x unlinkItem "NVGoggles_OPFOR";
					_x unlinkItem "NVGoggles_INDEP";
					_x removePrimaryWeaponItem "acc_pointer_IR";
					_x addPrimaryWeaponItem "acc_flashlight";
					_x enablegunlights "forceOn";
				};		
			if (isnil "master") then {} else {
					master addCuratorEditableObjects [[_x],true];
				};
			if (isnil "master_1") then {} else {
					master_1 addCuratorEditableObjects [[_x],true];
				};
		};
	} forEach allUnits;
};

doesn't work anymore... It worked just a week ago and now it stopped working - arma 3 says _x would be undefined... And I don't know why. I tried adding the forEach allUnits; to every if (sie _x == side XYZ)-block but it won't do...

Share this post


Link to post
Share on other sites

It stopped working? Had this problem with a script yesterday^^

So even if its not working anymore, how did it work? Perhaps it does in ArmA 2 ;D

What do "A", "LIST" and "OF" contain?

Share this post


Link to post
Share on other sites
It stopped working? Had this problem with a script yesterday^^

So even if its not working anymore, how did it work? Perhaps it does in ArmA 2 ;D

What do "A", "LIST" and "OF" contain?

oh... I haven't even noticed this is the A2OA-section... I thought, we were in the A3-section. :D In this case of course the BIS_fnc_MP has to be changed to something A2-like...

But it's not "A", "LIST" and "OF", but rather:

       [ "A",
       "LIST",
       "OF",
       "THE",
       "VEHICLES",
       "TO",
       "WHICH",
       "YOU",
       "WANT",
       "YOUR",
       "ACTIONS",
       "TO",
       "BE",
       "ATTACHED",
       "TO"
       ];

Edited by Pergor

Share this post


Link to post
Share on other sites

Yah but how would I create this list? It should be a variable list so I cant just add names.

And I still dont get how to list every vehicle which is in a trigger ._.

Share this post


Link to post
Share on other sites
Yah but how would I create this list? It should be a variable list so I cant just add names.

And I still dont get how to list every vehicle which is in a trigger ._.

Ah, I've read over the trigger requirement... So we're back to the beginning again. :D

How about an if-check with https://community.bistudio.com/wiki/in_location?

Share this post


Link to post
Share on other sites

{_x addAction ["LOAD VEHICLE","Support\constructions.sqf","ConStru",1,false,false,"","((_target distance _this) <6)"]} foreach ( nearestobjects [thistrigger,["car","tank","AIR","boat"],50])

Share this post


Link to post
Share on other sites

Alright I will try this out!!!

nearestObjects may be a solution, but I need to have an ellipse not a radius. And a certain angle of that area.

It is really frustrating that I just cant use the trigger area I already created in the editor by using forEach vehicles thislist !

So those are all workarounds which doesnt work the way I want it.

Is there really no way to refer to the list of vehicles inside a trigger?

Edited by _qoR

Share this post


Link to post
Share on other sites

The first method works fine for me only adding it to the vehicle.

The action shows only when you walk within 6 meters, if you only want it for the driver only then you need to change the addaction condition. ( driver _target == _this)

However you should get away from triggers as they won't work if a vehicle is in the trigger and another enters unless you force condition change.

Then you have the problem of the first vehicle gets another action added, so then you have to do more scripting to prevent this using arrays or variables to keep track of the action.

Your then left with another issue of removing the action when not in a trigger. how will the trigger know when you left the are on deac only works if all the detected units have left.

You see how it starts to get complicated.

One approach would be to add the action to all vehicles and then just use the actions condition to check that it's in the trigger.

That allows oval triggers and only one action used and it turns off when out of the trigger area.

needs function module placed on map and trigger needs a name, use that name in condition. example named mytrig

this addAction ["LOAD VEHICLE","Support\constructions.sqf","ConStru",1,false,false,""," driver _target == _this and [mytrig ,vehicle _this] call  bis_fnc_inTrigger "]

trigger setting are not important as only the size is needed

Edited by F2k Sel

Share this post


Link to post
Share on other sites

After some modifying it works for me with nearestObjects. There is no oval area but I guess this is satisfying.

Perhaps creating more triggers will do this...

Gonna try bis_fnc_inTrigger. Guess its helpful for other scenarios!

Thanks a lot F2k Sel!

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  

×