• Which the release of FS2020 we see an explosition of activity on the forun and of course we are very happy to see this. But having all questions about FS2020 in one forum becomes a bit messy. So therefore we would like to ask you all to use the following guidelines when posting your questions:

    • Tag FS2020 specific questions with the MSFS2020 tag.
    • Questions about making 3D assets can be posted in the 3D asset design forum. Either post them in the subforum of the modelling tool you use or in the general forum if they are general.
    • Questions about aircraft design can be posted in the Aircraft design forum
    • Questions about airport design can be posted in the FS2020 airport design forum. Once airport development tools have been updated for FS2020 you can post tool speciifc questions in the subforums of those tools as well of course.
    • Questions about terrain design can be posted in the FS2020 terrain design forum.
    • Questions about SimConnect can be posted in the SimConnect forum.

    Any other question that is not specific to an aspect of development or tool can be posted in the General chat forum.

    By following these guidelines we make sure that the forums remain easy to read for everybody and also that the right people can find your post to answer it.

Detect when in an active flight?

Messages
46
Country
israel
Hi,
I was checking this thread:

And subscribed to the events of Sim, SimStart and SimStop, but unfortunantly, it seems that always when moving into and out of a flight, it fired stop, start, stop, start.
Firing multiple and incorrect event is ugly enough, but if it ends in a state I can't tell what happens isn't good at all!

has anyone found a reliable way of detecting whether the client is in an active flight (i.e not in the main menu)?

For example, this is the output of exiting a flight:
FSTRaK.exe Information: 0 : 2023-05-04 21:10:42.312 +03:00 [Information] Closest Airport: KDEN Distance: 927.120603887454 meters, there are 9585 airports
2023-05-04 21:10:42.703 +03:00 [Debug] === Sim Stop
2023-05-04 21:10:42.703 +03:00 [Debug] === Sim 0
2023-05-04 21:10:43.929 +03:00 [Debug] === Sim Start
2023-05-04 21:10:43.929 +03:00 [Debug] === Sim 1
2023-05-04 21:10:44.746 +03:00 [Debug] Just Flight 146-100 Air France Express
2023-05-04 21:10:44.747 +03:00 [Debug] My coords: 39.8533362352615 : -104.673097109696
FSTRaK.exe Information: 0 : 2023-05-04 21:10:44.747 +03:00 [Information] Closest Airport: KDEN Distance: 927.120603887454 meters, there are 9720 airports
2023-05-04 21:10:45.706 +03:00 [Debug] === Sim Stop
2023-05-04 21:10:45.707 +03:00 [Debug] === Sim 0
2023-05-04 21:10:58.387 +03:00 [Debug] === Sim Start
2023-05-04 21:10:58.387 +03:00 [Debug] === Sim 1


Generated by this code:
private void simconnect_OnRecvEvent(SimConnect sender, SIMCONNECT_RECV_EVENT data)
{
switch (data.uEventID)
{
case (int)EVENTS.CRASHED:
Log.Debug("=== crashed");
break;
case (int)EVENTS.SIM_START:
Log.Debug("=== Sim Start");
break;
case (int)EVENTS.SIM_STOP:
Log.Debug("=== Sim Stop");
break;
case (int)EVENTS.SIM:
Log.Debug($"=== Sim {data.dwData.ToString()}");
break;
}
}
 
Hi Oren,

I think maybe you need to define "active flight" more specifically. For example consider that the main sim menu is also loaded as a "flight" (literally a "MainMenu.FLT" (sp?) file). You can listen for when a flight is loaded using another of the System events ("FlightLoaded" or something like that). There are also various "Pause States" the sim goes through as its loading up a flight, and the intermediate "ready to fly" screen is during one of these pause types (the new "Pause_EX1" with a value of `1`, IIRC). There are some other indicators I think may also be useful, like time passing in the simulator perhaps. So that's what I mean by defining the flight/aircraft state you're looking for more specifically. If you're logging flight data for example, maybe you care more about the pause states than the actual flight.

-Max
 
I am logging flight data.
Passing time is somethig I didn't think of.
A. lot to try...
 
Last edited:
Back
Top