Jump to content
tebbbs

Loop over all vehicles and add action to it

Recommended Posts

I want to loop over all vehicles and add an action to it (also those vehicles, that i spawn with Zeus) how do i do that?

Share this post


Link to post
Share on other sites

i know what a foreach loop is.. but arma 3 is a pita when its about locality.. thats the main issue i had in the past and before i start over again, i though someone knows exactly in which file and where i have to put it..

 

On 8/12/2020 at 2:06 PM, Harzach said:

 

i dont think so.. this will be part of a small mod

Share this post


Link to post
Share on other sites
24 minutes ago, tebbbs said:

i know what a foreach loop is.. but arma 3 is a pita when its about locality.. thats the main issue i had in the past and before i start over again, i though someone knows exactly in which file and where i have to put it..

 

 

i dont think so.. this will be part of a small mod

 

Then start a topic for the development of your mod. As it is, this is a scripting topic.

I'm not rules-lawyering, though it is indeed a forum rule. The point is that putting your topic in the wrong subforum can result in fewer eyes on it.

  • Like 1

Share this post


Link to post
Share on other sites
On 8/12/2020 at 11:26 AM, tebbbs said:

I want to loop over all vehicles and add an action to it (also those vehicles, that i spawn with Zeus) how do i do that?

 

So your key issue is that you want to add actions to every spawned vehicle?

In this case, a loop would be a very inefficient solution.

 

You can use init Eventhandlers in the vehicle's config:

https://community.bistudio.com/wiki/Arma_3:_Event_Handlers#Init

  • Like 1

Share this post


Link to post
Share on other sites

5 sec. loop:

private "_vehicles";

private _array = [];

while { (True) } do
{
    _vehicles = (vehicles - _array);
    
    if (True) then
    {
        if (_vehicles isEqualTo [] ) exitWith {};
        
        _array append _vehicles;
        
        {_x addAction ["Your action here!", {} ]; } forEach _vehicles;
    };
    
    sleep 5;
};
  • Like 1

Share this post


Link to post
Share on other sites

Better yet : instead of creating numerous actions, add one single action that works for all vehicles to the player itself.

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

×