#include <stdio.h>
#include <string.h>
#include "XPLMPlanes.h"
#include "XPLMUtilities.h"

static int	enable_count = 0;


PLUGIN_API int XPluginStart(
						char *		outName,
						char *		outSig,
						char *		outDesc)
{
	strcpy(outName, "planes_test");
	strcpy(outSig, "xplanesdk.examples.plane_test");
	strcpy(outDesc, "A quick test of airplane acquisition.");

	return 1;
}

PLUGIN_API void	XPluginStop(void)
{
}

PLUGIN_API void XPluginDisable(void)
{
}

PLUGIN_API int XPluginEnable(void)
{
	++enable_count;
	if (enable_count == 1)	return 0;

	int r = XPLMAcquirePlanes(NULL, NULL, NULL);
	
	if(r == 0)	XPLMDebugString("Plane test: did not acquire plane.s\n");
	else		XPLMDebugString("Plane test: did acquire plane.s\n");
	if(r)
	{
		char buf[1024];
		XPLMPluginID who;
		int total_before, active_before,total_after,active_after;
		XPLMCountAircraft(&total_before,&active_before,&who);
		XPLMSetActiveAircraftCount(total_before > 2 ? 2 : total_before);
		XPLMCountAircraft(&total_after,&active_after,&who);
		sprintf(buf,"Before: %d of %d, after: %d of %d\n",
			active_before,total_before,active_after,total_after);
		XPLMDebugString(buf);
	}
	
	return 1;
}

PLUGIN_API void XPluginReceiveMessage(
					XPLMPluginID	inFromWho,
					int				inMessage,
					void *			inParam)
{
}

One comment on “AcquirePlaneTest

  1. Good job
    I tested this code and it works very well.
    My question is:
    How can I control the added planes? . I want to start from this example to create an ATC Game.
    thank you in advance

Leave a Reply

Your email address will not be published. Required fields are marked *

Please do not report bugs in the blog comments.
Only bugs reported via the X-Plane Bug Reporter are tracked.