# SimConnect_AISetAircraftFlightPlan The **SimConnect\_AISetAircraftFlightPlan** function is used to set or change the flight plan of an AI controlled aircraft.   ##### Syntax ``` cpp HRESULT SimConnect_AISetAircraftFlightPlan( HANDLE hSimConnect, SIMCONNECT_OBJECT_ID ObjectID, const char* szFlightPlanPath, SIMCONNECT_DATA_REQUEST_ID RequestID ); ```   ##### Parameters {{< table-wrapper >}} | Parameter | Description | Type | |--------------------|--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|---------| | *hSimConnect* | Handle to a SimConnect object. | Integer | | *ObjectID* | Specifies the server defined object ID. | Integer | | *szFlightPlanPath* | Null-terminated string containing the path to the flight plan file. Flight plans have the extension .pln, but no need to enter an extension here. The easiest way to create flight plans is to create them from within the simulation, and then save them off for use with the AI controlled aircraft. | String | | *RequestID* | Specifies the client defined request ID. | Integer | {{< /table-wrapper >}}   ##### Return Values The function returns an **HRESULT**. Possible values include, but are not limited to, those in the following table. {{< table-wrapper >}} | Return value | Description | |--------------|-------------------------| | S\_OK | The function succeeded. | | E\_FAIL | The function failed. | {{< /table-wrapper >}}   ##### Remarks The following errors may apply to AI objects (refer to the [SIMCONNECT\_EXCEPTION](../structures-and-enumerations/simconnect-exception/) enum for more details): - `SIMCONNECT_EXCEPTION_LOAD_FLIGHTPLAN_FAILED` - `SIMCONNECT_EXCEPTION_OPERATION_INVALID_FOR_OBJECT_TYPE` - `SIMCONNECT_EXCEPTION_ERROR`   Typically this function would be used some time after the aircraft was created using the [SimConnect\_AICreateParkedATCAircraft](simconnect-aicreateparkedatcaircraft/) call.