Callum 0 Posted July 9, 2017 Report Share Posted July 9, 2017 Hi guys Trying to delete AI Traffic through FSUIPC using C#. Have successfully got it to list all of the AI. I am just having problems deleting it. Using the code Paul gave here: http://forum.simflight.com/topic/79906-send-control-to-a-simobject/ But in my case, traffic do not seem to go away. The Offsets I am declaring: private Offset<int> id = new Offset<int>(0x2904); private Offset<int> ctrl = new Offset<int>(0x2908); private Offset<int> val = new Offset<int>(0x2900); private AITrafficServices AI; The code (this should remove each AI plane - but it does not). I know it isn't the foreach which is the problem because I can get it to list all of the AI just fine (I removed that here to avoid confusion) foreach (AIPlaneInfo plane in FSUIPCConnection.AITrafficServices.AllTraffic) { id.Value = plane.ID; ctrl.Value = 65535; // delete ai traffic val.Value = 1; // Set to 1 for true FSUIPCConnection.Process(); } I think the problem might lie in either the plane.ID or sending the control - although it is the same code as what was suggested in the link above. Many thanks for your help!! Quote Link to post Share on other sites
Thomas Richter 31 Posted July 9, 2017 Report Share Posted July 9, 2017 Hi, check your Offsets against Bytes 0–3: Aircraft Id (from the TCAS table)Bytes 4–7: The FS Control (see published lists) Bytes 8–11: A parameter for the control, if needed Thomas Quote Link to post Share on other sites
Callum 0 Posted July 9, 2017 Author Report Share Posted July 9, 2017 Hey Thomas Thanks for the reply. Should I get and use the ID from which my code pulls or the one in Trafficlook? For example, one AI in traffic look has the ID of 38, but in my code it is -38. In my code I am using the -38 one (all of mine are negative, but Trafficlooks are positive). The FS Control is 65535, which in the published offsets is for deleting the AI aircraft. I am not too sure on the Parameter, but setting it to 1 for true, seems logical? I presume I am writing the controls correctly?? I also tried just using '38' and '-38' in the ID value, instead of plane.ID. This did not work either. Cheers Quote Link to post Share on other sites
Thomas Richter 31 Posted July 9, 2017 Report Share Posted July 9, 2017 But did you check your Offsets as I said? I.e. byte 4-7 is the control but have assigned private Offset<int> id = new Offset<int>(0x2904); what is byte 0-3 ... Thomas Quote Link to post Share on other sites
Callum 0 Posted July 9, 2017 Author Report Share Posted July 9, 2017 Sorry, I am not really sure what I am supposed to be checking for. I have used the exact same offsets which Paul posted on here before. Quote Link to post Share on other sites
Callum 0 Posted July 9, 2017 Author Report Share Posted July 9, 2017 I got it working! Thanks!!! Quote Link to post Share on other sites
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.