- Messages
- 175
- Country
Here is how to set AI Traffic density from a custom DLL loaded by FSX
Hi,
I just discovered a way for set the AI Traffic density, automatly, from a DLL written in C++. Here is the basic code:
This is for anyone wanting to change the traffic settings dynamicly from your DLL...
Manuel Ambulo
Hi,
I just discovered a way for set the AI Traffic density, automatly, from a DLL written in C++. Here is the basic code:
Code:
// FS10 FS-TRAFFIC.DLL - Settings Structure
typedef struct FS10TRAFFIC_SETTINGS
{
unsigned long Traffic_Density; // Traffic Density %(percent, from 0 to 100)
unsigned long IFR_or_VFR; // 0 = IFR and VFR, 1 = IFR (Only)
unsigned long Airline; // 0 = Disable, 1 = Enabled
unsigned long General_Aviation; // 0 = Disable, 1 = Enabled
} FS10TRAFFIC_SETTINGS;
// FS10 - Exported Function Pointers Types Definitions
typedef void (FSAPI *FS10TRAFFICWRITESETTINGS)(FS10TRAFFIC_SETTINGS* info);
typedef void (FSAPI *FS10TRAFFICREADSETTINGS)(FS10TRAFFIC_SETTINGS* info);
FS10TRAFFIC_SETTINGS FS10Traffic_Settings;
// Initializate this structure
memset(&FS10Traffic_Settings, 0, sizeof(FS10TRAFFIC_SETTINGS));
// Get the handle of the TRAFFIC.DLL module
hTraffic = GetModuleHandle("FS-TRAFFIC.DLL");
// READ AND CHANGE THE TRAFFIC SETTINGS
// If we got the handle of the TRAFFIC.DLL module then
if (hTraffic != NULL)
{
// 1) READ THE CURRENT TRAFFIC SETTINGS
// Get a pointer to the TRAFFIC.DLL module's exported function
FS10ReadTrafficSettings = (FS10TRAFFICREADSETTINGS)GetProcAddress(hTraffic, (char*)6);
// If we got a pointer to the TRAFFIC.DLL module's exported function then
if (FS10ReadTrafficSettings != NULL)
{
// Get the *CURRENT* traffic settings
FS10ReadTrafficSettings(&FS10Traffic_Settings);
// Notify to user
MessageBox(hWnd, "The traffic settings had been read SUCCESSFULLY!", "FSIntruder.dll - Message", 0);
}
// 2) CHANGE THE TRAFFIC SETTINGS
// Get a pointer to the TRAFFIC.DLL module's exported function
FS10WriteTrafficSettings = (FS10TRAFFICWRITESETTINGS)GetProcAddress(hTraffic, (char*)5);
// If we got a pointer to the TRAFFIC.DLL module's exported function then
if (FS10WriteTrafficSettings != NULL)
{
// Build the new traffic settings structure
FS10Traffic_Settings.Traffic_Density = 100; // 100% of Traffic density
FS10Traffic_Settings.IFR_or_VFR = 0; // IFR and VFR
FS10Traffic_Settings.Airline = TRUE; // Enabled
FS10Traffic_Settings.General_Aviation = TRUE; // Enabled
// Set the *NEW* traffic settings
FS10WriteTrafficSettings(&FS10Traffic_Settings);
// Notify to user
MessageBox(hWnd, "The traffic settings had been CHANGED SUCCESSFULLY!", "FSIntruder.dll - Message", 0);
}
}
This is for anyone wanting to change the traffic settings dynamicly from your DLL...
Manuel Ambulo
Last edited: