• 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.

SimConnect_RequestSystemState() Wrong value

Messages
10
Country
france
Hi (sorry in advance for my bad english),

I'm trying to get the flying state value toward the SimConnect_RequestSystemState() funtion.
The funtion doesn't return any error, but the value of the flying state is always 0 no matter what, even when I'm currently flying.

This is the code :
------------------------------------------------------------------
HANDLE ScDefaultHandle;
char* szState;
szState=strdup("Sim");

SIMCONNECT_RECV_SYSTEM_STATE fsxStateStruct;
SIMCONNECT_RECV fsxStateTempStruct;
SIMCONNECT_RECV_ID fsxStateStructType = SIMCONNECT_RECV_ID_SYSTEM_STATE;

fsxStateTempStruct.dwID = fsxStateStructType; //only used to refresh the dwID attribute in order to //receive the returned structure by the SimConnect_RequestSystemState() funtion.

SIMCONNECT_DATA_REQUEST_ID fsxRequestStateID;
fsxRequestStateID=7777;
fsxStateStruct.dwRequestID=fsxRequestStateID;

SimConnect_RequestSystemState(ScDefaultHandle, fsxRequestStateID, szState);

cout<<"Flying state = "<<fsxStateStruct.dwInteger<<endl; //0 or 1 (but in my case, it's always 0)
------------------------------------------------------------------

So, shouldn't the fsxStateStruct.dwInteger attribute be correct ? What is wrong in this code ? I though I had respected all the points specified in the big SimConnect documentation... A bit disapointed :(

I had to regroup all those lines, because they was all dispatched here and there in the code. So maybe I did a mistake in the order of the lines ? Maybe the fsxStateTempStruct.dwID refreshing isn't at the good moment in the code ?

Thanks in advance for your help.

Regards
 
I suggest looking at the DialogBoxMode example in the SDK. When a SimConnect request is made, the response will occur in the SimConnect callback. The code you have shown tells nothing about how you have set your SimConnect project up. It doesn't use function returns or even output parameters in the functions but rather events triggered in the SimConnect callback to provide the response to your request.
 
Back
Top