I am posting your solution in this thread so that others who also want to know how to do this may learn as well. This is not how this is normally done. This will help you achieve what you want to accomplish, but just handing the solution over will not help you learn how to do it on your own. As such, Once you have this working, I challenge you to dissect it and learn WHY it works. Doing so will help you become a stronger scripter/config writer/addon maker.
Again, refer to the guidance I gave you in the posts above. Inside them are all the steps/reference material you would have needed to create the below.
This is an A-Z guide to make your script(s) work in an addon.
1. Create a folder named "@gunner_switch". Put whatever name you want after the "@" but be consistent in whatever you choose. I will use "gunner_switch" for the remainder of this example.
2. Inside "@gunner_switch" create a subfolder called "Addons".
3. Inside "Addons" create another subfolder called "gunner_switch".
4. Inside "gunner_switch" place the following files:
Swap_Actions.sqf
To_Driver.sqf
To_Gunner.sqf
$PBOPREFIX$
config.cpp
5. Open $PBOPREFIX$ in a text editor and enter this single line of text with no whitespace before or after the text:
gunner_switch
6. Put this in your config.cpp:
Code:
class CfgPatches
{
class gunner_switch
{
units[] = {};
weapons[] = {};
requiredVersion = 1.0;
requiredAddons[] = {"Extended_EventHandlers"};
};
};
class Extended_Init_EventHandlers
{
// Define the classes to add inits to.
class Air
{
// Add init lines to be run on all units that inherit from this class.
gunner_switch_Init_Air="_this execVM ""\gunner_switch\Swap_Actions.sqf"";";
};
};
This will add an init XEH to all "Air" class vehicles. If you want to limit it to only a certain sub class then change "Air" to whatever you want.
7. Pack you PBO and ensure that you have @gunner_switch and @CBA installed and running.
8. Place a helo in game and the actions should appear when inside.