Jump to content
Sign in to follow this  
75thRanger

Any one want to help me make a config.cpp for a script?

Recommended Posts

Ive tried numerous time but i got frustrated and deleted the whole config i made stupid decision on my part i was wondering if some could help me. heres the two script files:

DAP_VehicleSeat_KeyCheck.sqf

private["_handled","_state","_vehicle","_driver","_gunner"];

_handled = false;

_dikCode = (_this select 1);

if (_dikCode == 47) then

{

_vehicle = vehicle player;

_state=0;

_gunner = gunner _vehicle;

_driver = driver _vehicle;

if ((isPlayer _driver) and (isPlayer _gunner)) then {_state=1;};

if (_state==0) then

{

if (!(isNil("_gunner"))) then

{

_gunner SetPos [getPos _vehicle select 0, getPos _vehicle select 1,-1000];

};

if (!(isNil("_driver"))) then

{

_driver SetPos [getPos _vehicle select 0, getPos _vehicle select 1,-1000];

};

if (!(isNil("_driver"))) then

{

_driver assignAsGunner _vehicle;

[_driver] OrderGetIn true;

_driver MoveInGunner _vehicle;

};

if (!(isNil("_gunner"))) then

{

_gunner assignAsDriver _vehicle;

[_gunner] OrderGetIn true;

_gunner MoveInDriver _vehicle;

};

};

_vehicle EngineOn true;

_handled = true;

};

_handled;

next script

DAP_VehicleSeatSwitch.sqf

_vehicle = _this select 0;

While {(alive _vehicle)} do

{

WaitUntil {sleep 1;(player in (crew _vehicle));};

DAP_Vehicle_Seat_Keycheck = compile preprocessFile "Scripts\DAP_VehicleSeat_KeyCheck.sqf";

_Vehicle_Seat_Keycheck_Eventhandler = (findDisplay 46) displayAddEventHandler ["keyDown","_this call DAP_Vehicle_Seat_Keycheck"];

WaitUntil {sleep 1;(!(player in (crew _vehicle)));};

(findDisplay 46) displayRemoveEventHandler ["keyDown",_Vehicle_Seat_Keycheck_Eventhandler];

};

can any one help me out? Thanks

***please note these scripts are made by the USER DAP & NOT ME*********0

Share this post


Link to post
Share on other sites

Hey 75thRanger,

Where your getting those scripts from, isn't there a cpp already?

is there an addon or pbo that those scripts are in? if so it should have a cpp already no?

can you link me to what you getting those from, ill take a look, i can tell you much but i can try.

Also when you paste script, and cpp codes, use the code icon above, looks like this #, just highlight and hit that button.

It helps distinguish stuff between each other, and keeps the thread clean, well to me it does anyways.

Also what happened with your other post, this one:

http://forums.bistudio.com/showthread.php?t=125795

I dont understand how you got something going and then dont work off of it, you got guys already helping you there,

to me your starting a new thread over another one pretty much asking the same thing unless your doing something new here.

Edited by Gnter Severloh

Share this post


Link to post
Share on other sites

I have a script but no config.cpp that otber post was asking for a script n this one is abot helping me create a config i tried a bunch but couldntvt it to work

Share this post


Link to post
Share on other sites

I am not sure it is cleat what you want your config to do and what the connection to the scripts is. What do you want to accomplish?

Share this post


Link to post
Share on other sites

What i want to do is make an action to sitch seats in a helicopter. ( for my optics mod to work right i have to start as gunner and switch to the pilot and be able to switch back to the gunner.) so i need to make and action to be seen in the menu when you move the mouse wheel ( you know when you see getin, get out, engine on etc. menu) so thhen you click switch seat and then you kove your seat in the helicopter)

Share this post


Link to post
Share on other sites

Ok, so if you want to make this into an addon, here are the things you will have to consider.

1) When do you want the action to appear?

I assume you only want it to appear when you are in a helicopter. You have to decide (if you have not already) whether you want to show the option in any helicopter or in a certain helo(s). In this case a GetIn event handler would probablt be the best method to trigger when this actions show. Read about it here and you should get familiar with all the different event handlers.

2) How to get the event handler / action / script to work as part of an addon.

You should really use Extended Event Handlers (part of CBA) to accomplish this. Read this to get familiar with XEH. You will probably want to use class Extended_GetIn_Eventhandlers.

3) Create your config.cpp.

The config.cpp will include your class CfgPatches and XEH sections. Again, my post here wil help

Get familiar with all of these concepts and see if you can put it together. You will run into roadblocks but these will help you learn as well. What you are trying to tackle. Although outwardly what you are trying to apperas simple, but you are trying to do some advanced things when it comes to scripting/addons. It took me a good 3 months and some extremely knoweldebale tutors before I was even comfortable with configs and addon making at the simplest of levels. Have patience and it will all come together.

Good luck!

Share this post


Link to post
Share on other sites

heres my config.cpp

class CfgPatches {

class Swap_Actions {

units = {};

weapons = {};

requiredAddons = {"Extended_EventHandlers"};

requiredVersion = 0.100000;

};

};

class Helicopter {

_nill = "_this execvm "Swap_Actions.sqf";";

};

};

----------The scripts im useing for the config.cpp------

Swap_Actions.sqf

_veh = _this select 0;

//Swap Actions

//------------

_veh addAction ["Move To Gunner" , "To_Gunner.sqf",[],0,false,false,"","(isplayer (driver _target)) and !(isplayer (gunner _target))"];

_veh addAction ["Move To Driver" , "To_Driver.sqf",[],0,false,false,"","!(isplayer (driver _target)) and (isplayer (gunner _target))"];

To_Driver.sqf

private ["_veh","_driver","_gunner"];

_veh = _this select 0;

_driver = driver _veh;

_gunner = gunner _veh;

_driver setpos [0,0,1];

_driver setVelocity [0, 0, 0];

waituntil {((_veh emptypositions "Driver") == 1)};

_gunner action ["moveToDriver", _veh];

_driver moveinGunner _veh;

_driver assignasGunner _veh;

To_Gunner.sqf

private ["_veh","_driver","_gunner"];

_veh = _this select 0;

_driver = driver _veh;

_gunner = gunner _veh;

_gunner setpos [0,0,1];

_gunner setVelocity [0, 0, 0];

waituntil {((_veh emptypositions "Gunner") == 1)};

_driver action ["moveTogunner", _veh];

_gunner moveindriver _veh;

_gunner assignasdriver _veh;

im not really sure how to add the other actions in the config.cpp any help or editing for me would be really appreciated. thanks -Joel-

Share this post


Link to post
Share on other sites

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:

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.

Share this post


Link to post
Share on other sites

Please sign in to comment

You will be able to leave a comment after signing in



Sign In Now
Sign in to follow this  

×