Jump to content
Sign in to follow this  
75thRanger

AH64 Gunner Script

Recommended Posts

Hey guys i was wondering if any one would help me create a script to allow the player to switch from the gunner seat to pilot seat. i am aware of the SLX car mod and GDT but to get the dunner sights to work i would have to start out as the gunner and switch to pilot and so fourth. Thanks -Joel-

Edited by 75thRanger

Share this post


Link to post
Share on other sites

yeah i have this but that just siwtcjes you to the optics i mean i want to just change the coclpit seating. like if your pilot then switch to the gunner seat not just use the optics. tanks any way bud.

Share this post


Link to post
Share on other sites

What about...

addSwitchableUnit _gunner;
selectplayer _gunner;

Share this post


Link to post
Share on other sites

He came to me in pm and hes using SLX, the file specifically is SLX_car gunner, hes trying to get his optics mod to work

with that so that he can switch to pilot automatically instead of gunner to get his sites to work.

You will have to look at the scripts in that file to get it to work with SLX, either that remove that file and create something new.

Heres the script, i had looked at it already and couldn't figure it out, had a rough idea but couldn't get it to work.

SLX_ManualGunner

[color="green"]// Let player driver remote control vehicle gunner.[/color]
_unit=_this select 0;

SLX_ManualGunner=gunner _unit;
player remoteControl gunner _unit;
_unit switchCamera "gunner";

SLX_ManualGunner_terminate=nil;	

_displayEH_keydown = (finddisplay 46) displayaddeventhandler ["keydown","
_key = _this select 1;

comment '--- END';
if (_key in (actionkeys 'menuback')) then {SLX_ManualGunner_terminate = true};

"];

waituntil {
(!isnil "SLX_ManualGunner_terminate")
|| 
(!alive _unit)
||
(!alive player)
||
(player!=driver _unit)
||
(!((gunner _unit) in (units player)))
||
(isplayer gunner _unit)
};


(finddisplay 46) displayremoveeventhandler ["keydown",_displayEH_keydown];
SLX_ManualGunner_terminate=nil;	
sleep .1;

objNull remoteControl SLX_ManualGunner;
vehicle player switchCamera "internal";

SLX_ManualGunner_AddAction

// Add action.
_unit=_this select 0;

_nic = _unit addAction ["Manual gunner","SLX_CarGunner\SLX_ManualGunner.sqf",[],0,false,true,"",

format [" 
(
(player==_this)
&&
(player==driver _target)
&&
((gunner _target) in (units player))
&&
(!isplayer gunner _target)
)

",0]];

Share this post


Link to post
Share on other sites

Yeah... he came to me in PM too.... several! What he wants is someone to modify that script to be able to switch between gunner and driver in a MP environment!... or come up with a script to do that.

Share this post


Link to post
Share on other sites

just trying to figure it out is all. i know some one knows how to and might be willing to help me. Like i said i know a little of scripting. when in comes to missions just dont know how to create a script to where i be able to do this is all. Thanks for the help tho. And also. the several pms were responding to what you have said. =-) i will try to modify this script to allow me to do so. and if i cant get it. im sure some one will help me and teach me how to do it. Thanks again -Joel-

Share this post


Link to post
Share on other sites

You sure are trying hard... I'll give you that! :)

Here mate.... try this see how much mileage you get out if it.

It will work in SP. Maybe someone can help you with the MP aspect..... or... hint hint... maybe you can try to do that yourself and then come back with questions.

Create a script called "toggle.sqf" in your mission folder. Put this in it:-

toggle.sqf

if (not (Toggle)) then {
Toggle=true;
} else {
Toggle=false;
};

Then create a script called "swapseat.sqf"...put this in it:-

swapseat.sqf:-

_run = true;
Toggle = true;
UnitSwitchesAdded = false;
while {_run} do {
_veh = vehicle player;
if (_veh isKindOf "Air") then {
	if (not (isnull (gunner _veh)) and not (UnitSwitchesAdded)) then {
		addSwitchableUnit (driver _veh);
		addSwitchableUnit (gunner _veh);
		_act = _veh addAction ["Toggle Seat", "toggle.sqf" ,[], -1, false];
		UnitSwitchesAdded = true;
	};
	while {_veh != player} do {
		if (not (Toggle) and gunner _veh != player) then {
			selectplayer gunner _veh;
			(group player) selectLeader player;
		};
		if (Toggle and driver _veh != player) then {
			selectplayer driver _veh;
			(group player) selectLeader player;
		};
		sleep 1;
	};
};
sleep 1;
};

Put this in your players init:-

nul = [] execVM "swapseat.sqf";

Now if you are in an AIR vehicle with a gunner you can switch using an Action.... but no doubt this script will raise other issues as you'll see.

EDIT: Added two lines of code that will allow you to tell the pilot where to go when you are the gunner.

Edited by twirly
Clarity

Share this post


Link to post
Share on other sites

this will work in SP / MP environments

a simple way to do it is

in the init of the chopper add

 _nill = [this] execVM "Swap_Actions.sqf";

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;

Edited by Zonekiller

Share this post


Link to post
Share on other sites

Yes but im going to use on a server so it would have to be aan action and being that i dont have ac ess tothe ini lne basically i want to replicate the slx cargunner mod butreverse it in a sense or gdt helicoptering mod etc. (Which as you know are mp scripts n you dont have to a ess the ini line but you can use them on a server) so basically it needs to be put into a pbo file so i can use it on a server which i know how to make pbo and keys

Edited by 75thRanger

Share this post


Link to post
Share on other sites

Why not just edit the existing cargunner.pbo file the script is already setup, you just need to adjust the code.

I now SLX works in Mp as I have it in COWarMod and it runs fine on my gameserver.

Share this post


Link to post
Share on other sites

Ive tried n nothing really seems to wirj when i edit the slx scripts. :(

Share this post


Link to post
Share on other sites

any one have an idea how i could make a config.cpp for Zonekillers script? any help appreciated

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  

×