To add an index when triggering an event that is specific to a particular engine (e.g., engine 1 or 2) or a master battery (e.g., master battery 1 or 2), you typically need to use custom SimConnect events that are defined to handle such scenarios. Here’s how you can do it:
- Define Custom SimConnect Events: First, you need to define custom SimConnect events for each specific scenario you want to handle. For example, you might define events like
ENGINE1_START
andENGINE2_START
orMASTER_BATTERY1_ON
andMASTER_BATTERY2_ON
. - Map Custom SimConnect Events: Use the
MapClientEventToSimEvent
method to map these custom SimConnect events to corresponding events in MSFS. For example:
csharpCopy code
simConnect.MapClientEventToSimEvent(EventID.ENGINE1_START, "ENGINE1_START");
simConnect.MapClientEventToSimEvent(EventID.ENGINE2_START, "ENGINE2_START");
simConnect.MapClientEventToSimEvent(EventID.MASTER_BATTERY1_ON, "MASTER_BATTERY1_ON");
simConnect.MapClientEventToSimEvent(EventID.MASTER_BATTERY2_ON, "MASTER_BATTERY2_ON");
- Trigger Events with Index: When you want to trigger these events with a specific index (e.g., engine number or master battery number), you can use the
TransmitClientEvent
method with the appropriate event and index. For example:
csharpCopy code
// To start engine 1
simConnect.TransmitClientEvent(0, EventID.ENGINE1_START, 1, GroupID.GROUP0, SIMCONNECT_EVENT_FLAG.GROUPID_IS_PRIORITY);
// To start engine 2
simConnect.TransmitClientEvent(0, EventID.ENGINE2_START, 1, GroupID.GROUP0, SIMCONNECT_EVENT_FLAG.GROUPID_IS_PRIORITY);
// To turn on master battery 1
simConnect.TransmitClientEvent(0, EventID.MASTER_BATTERY1_ON, 1, GroupID.GROUP0, SIMCONNECT_EVENT_FLAG.GROUPID_IS_PRIORITY);
// To turn on master battery 2
simConnect.TransmitClientEvent(0, EventID.MASTER_BATTERY2_ON, 1, GroupID.GROUP0, SIMCONNECT_EVENT_FLAG.GROUPID_IS_PRIORITY);
In the above code, we are using different custom SimConnect events (ENGINE1_START
, ENGINE2_START
, MASTER_BATTERY1_ON
, and MASTER_BATTERY2_ON
) to trigger specific actions for engine or master battery control. The index (in this case, 1) indicates that you want to perform the action on the first engine or the first master battery. You can adjust the index as needed for your specific use case.
doesn’t work for me