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

[Beatle's DLL]WPF & SimConnect

Messages
73
Hi everyone,

I have an issue, when I try to remove an AI aircraft. The creation works perfectly I also retrive the ObjectID to interact with this particular object later and try to remove it. But when I click on my button who trigger the AIRemoveObject method, sometimes my AI aicraft is deleted sometimes not. I don't understand why.

Let's see my code :

AI aicraft creation :

Code:
private void requestTanker(object sender, RoutedEventArgs e)
        {
            if (gConnected != false && gSimConnect != null)
            {
                if (gTanker == null)
                {
                    gSimConnect.AICreateEnrouteATCAircraft("Boeing 737-800", "N100", 100, Config.APPLICATION_PATH + "tanker/TANKER_FPLAN", 0.0f, false, RequestIDs.REQUEST_TANKER);
                }
            }

OnRecvAddRemove event :

Code:
private void SimConnect_OnRecvAddremove(SimConnect sender, SIMCONNECT_RECV_EVENT_OBJECT_ADDREMOVE data)
        {
            switch (data.uEventID)
            {
                case (uint)EventIDs.TANKER_ADDED:
                    if (data.dwData != 0 && gTanker == null)
                    {
                        gTanker = new Tanker(data.dwData);

                        gSimConnect.Text(SIMCONNECT_TEXT_TYPE.PRINT_BLUE, 0, RequestIDs.REQUEST_TEXT, "TANKER ENROUTE");

                        gSimConnect.RequestDataOnSimObject(RequestIDs.REQUEST_TANKER,
                            gTanker.ObjectID,
                            SIMCONNECT_PERIOD.VISUAL_FRAME,
                            SIMCONNECT_DATA_REQUEST_FLAG.CHANGED,
                            gTanker);
                    }
                    break;

                case (uint)EventIDs.TANKER_REMOVED:
                    gTanker = null;
                    break;
            }
        }

AI aicraft Removing :

Code:
private void releaseTanker(object sender, RoutedEventArgs e)
        {
            if (gConnected != false && gSimConnect != null)
            {
                if (gTanker != null)
                {
                    gSimConnect.AIRemoveObject(gTanker.ObjectID, RequestIDs.REQUEST_TANKER);
                }
            }
        }

The Tanker class :

Code:
using BeatlesBlog.SimConnect;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace VASF
{
    [DataStruct()]
    public class Tanker : System.ComponentModel.INotifyPropertyChanged
    {
        public Double PLANE_LATITUDE;
        public Double PLANE_LONGITUDE;
        public Int32 PLANE_ALTITUDE;
        public Int32 PLANE_ALT_ABOVE_GROUND;
        public Int32 VERTICAL_SPEED;
        public Int32 GROUND_VELOCITY;
        public Boolean SIM_ON_GROUND;

        private UInt32 eObjectID;

        public Tanker(UInt32 eObjectID)
        {
            this.eObjectID = eObjectID;
        }

        public Tanker()
        {
        }

        public UInt32 ObjectID
        {
            get
            {
                return eObjectID;
            }
            set
            {
                eObjectID = value;
            }
        }

        [DataItem("Plane Latitude", "degrees")]
        public Double LatitudeDegrees
        {
            get
            {
                return PLANE_LATITUDE;
            }
            set
            {
                PLANE_LATITUDE = value;
                RaisePropertyChanged("LatitudeDegrees");
            }
        }

        [DataItem("Plane Longitude", "degrees")]
        public Double LongitudeDegrees
        {
            get
            {
                return PLANE_LONGITUDE;
            }
            set
            {
                PLANE_LONGITUDE = value;
                RaisePropertyChanged("LongitudeDegrees");
            }
        }

        [DataItem("Plane Altitude", "feet")]
        public Double AltitudeFeet
        {
            get
            {
                return PLANE_ALTITUDE;
            }
            set
            {
                PLANE_ALTITUDE = (Int32)Math.Round(value);
                RaisePropertyChanged("AltitudeFeet");
            }
        }

        [DataItem("Plane Alt Above Ground", "feet")]
        public Double AltitudeAboveGroundFeet
        {
            get
            {
                return PLANE_ALT_ABOVE_GROUND;
            }
            set
            {
                PLANE_ALT_ABOVE_GROUND = (Int32)Math.Round(value);
                RaisePropertyChanged("AltitudeAboveGroundFeet");
            }
        }

        [DataItem("Vertical Speed", "feet")]
        public Double VerticalSpeedFeet
        {
            get
            {
                return VERTICAL_SPEED;
            }
            set
            {
                VERTICAL_SPEED = (Int32)Math.Round(value);
                RaisePropertyChanged("VerticalSpeedFeet");
            }
        }

        [DataItem("Ground Velocity", "knots")]
        public Double GroundVelocityKnots
        {
            get
            {
                return GROUND_VELOCITY;
            }
            set
            {
                GROUND_VELOCITY = (Int32)Math.Round(value);
                RaisePropertyChanged("GroundVelocityKnots");
            }
        }

        [DataItem("Sim On Ground", "bool")]
        public Boolean SimOnGroundBool
        {
            get
            {
                return SIM_ON_GROUND;
            }
            set
            {
                SIM_ON_GROUND = value;
                RaisePropertyChanged("SimOnGroundBool");
            }
        }

        #region INotifyPropertyChanged Members

        public event System.ComponentModel.PropertyChangedEventHandler PropertyChanged;

        private void RaisePropertyChanged(string propertyName)
        {
            if (this.PropertyChanged != null)
            {
                this.PropertyChanged(this, new System.ComponentModel.PropertyChangedEventArgs(propertyName));
            }
        }

        #endregion
    }
}

Thank you in advance and sorry for my bad english.
 
Hello,

I found a solution and it works perfectly. The only issue I have is in multiplayer mode.

In fact, the AI trafic is well deleted for me but for others players they still see it.

Have you some idea ?

Thank you.
 
To help others, can you post your solution?

As far as I know, you can't delete AI from other users in multiplayer. All SimObjects are instantiated locally. Multiplayer is just a special case where FSX will automatically synchronize airplane and helicopter objects between clients.
 
Hello ollyau,

I will of course post my solution tonight after work.

For the delete action, I don't speak about AI created by other client, but I speak about one AI create by my client and when I delete it the other players (in multiplayer) still see this AI.

Thank you.
 
Sorry, I suppose my sentence was ambiguous.

I meant to confirm the behavior you found: that the deletion of AI from the local computer doesn't propagate to other clients in multiplayer.
 
Back
Top