Jump to content
pierremgi

OnTeamSwitch, teamSwitch... who masters this command?

Recommended Posts

Hi all,

Here is one of the more time wasting command as it works sometimes, but never in a reliable manner.

I took time to dismount all my scripts and I'm referring to a simple standard basic mission with just 3 playable units, no enemy, no script.

Arma 3 V 1.58.

 

A trigger or a little script with:

 

0 = [] spawn {onTeamSwitch { hint "blah blah"}}; in an unconditional trigger works... but not in more complex mission.

 

0 = [] spawn {addMissionEventHandler ["teamSwitch",{hint "blah blah"}]} doesn't work. (spawned or not) This should work since 1.57.

 

Of course, BI writing about stackable version, I just tried for "fun":

0 = [] spawn { ["blabla","onTeamSwitch",{hint "blah blah"}] call bis_fnc_addStackedEventHandler }; It was not supposed to work and I confirm it doesn't.

 

 

So, at this time, I would like to know how to make reliable the basic onTeamSwitch. I got it sometimes, without explanation.

the [] spawn {onTeamSwitch { hint "blah blah"}}; is on the start script of an addon triggering other eventHandlers, MEH like draw3D, EH like "fired",

or onMapSingleClick, fine also.

All of them works well. Where ever I place this onTeamSwitch, spawned or not, it fails.

I even tried to loop it each 2 seconds... just to test. No result.

 

So if you have some workable code with this command, proven in trial by fire on large scripts, many many thanks.

 

 

 

Share this post


Link to post
Share on other sites

Yes.

I tried also in a SP mission with no success. I'm looking for an explanation on my side.

Share this post


Link to post
Share on other sites

There is a known problem with mission event handlers implementation in 3DEN. Could you please try the same but in 2DEN and report back?

Share this post


Link to post
Share on other sites

No joy. Exactly the same results In 2D editor, Arma 3 + BI DLC, no mod, 4 playable units and nothing else but the trigger.

 

0 = [] spawn {onTeamSwitch { hint "blah blah"}}; in an unconditional trigger works.

0 = [] spawn {addMissionEventHandler ["teamSwitch",{hint "blah blah"}]} doesn't work.

 

On an other level:

I had to stay with the "old" onTeamSwitch version for my addon (on Steam now). But, with several and diverse EHs (all working fine), I had to loop this one! I guess it's mad and poorly written, but this didn't work before (or just one time):

 

[] spawn {
  while {!isMultiplayer} do {
    onTeamSwitch {
      if (isnil "keys") then {keys = (findDisplay 46) displayAddEventHandler ["keyDown", "_this call TP_keys"]};
      _from enableAI "TEAMSWITCH";    // seems to be mandatory for a better AI behavior after switch
      call MGI_fnc_addingActions; //  don't run if no loop!
        };
  sleep 1;
}};

 

Other EHs , like draw3D, fired, firedNear,... are far more easier and reliable.

I'm looking also a way to recover my displayAddEventHandler "keyDown" (in a sqf called by the config.cpp) when resuming a mission (exit and resume or load a saved one). I don't know what is the engine's behavior, but all goes well (draw3D and else) except this EH "keydown".

Share this post


Link to post
Share on other sites

Spawning a code is just an habit, using trigger or console with bunch of local variables. Sometimes, guys on armaHolic ask for a code and I don't need to create an init.sqf for testing it.

I admit this is not useful here! Of course I tested directly EH, with no more success. That doesn't seem to make difference.

Share this post


Link to post
Share on other sites

If we are talking about the mission, It takes less time to place 4 playable units on Stratis or Altis, write in console or add an unconditional trigger with:

addMissionEventHandler ["teamSwitch",{hint "blah blah"}] - result 0% working

or

onTeamSwitch { hint "blah blah"} - result 100% working for this basic situation.

2D or 3D editor.

 

If we are talking about my post #5, it's an add-on which works (except keydown EH when saving/resuming a mission but it's another problem).

I just had to loop the onTeamSwitch, I don't know why. pbo is already on Steam: http://steamcommunity.com/sharedfiles/filedetails/?id=673533220 .

Share this post


Link to post
Share on other sites

Sorry, but I dont understand, what do you mean by unconditional trigger and where do you insert addMissionEventHandler?

Share this post


Link to post
Share on other sites

KK,

open editor. No matter the map.

Place 3 or 4 playable units.

Place a trigger, no dimension. Unconditional means you delete 'this' in condition field. This will fire the trigger without condition, at start of the mission, but I guess you know that!

In the on act field of this trigger:  addMissionEventHandler ["teamSwitch",{hint "blah blah"}]

 

or if you prefer, disregard the trigger and write this code in debug console.

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

×