Jump to content
Sign in to follow this  
fruity_rudy

Only pilots are able to fly .. Need help with that

Recommended Posts

Hey there. i need some help . I wanna add Civs as a 4th playable group next to blu, op and res . These guys are pilots who can be hired by the players to fly them around. How can i edit the planes and choppers, so it checks (like in domination) if player is pilot or not. Is there any easy way to modify that??

thx for any help

Share this post


Link to post
Share on other sites

you could add a "getin" eventhandler to the vehicles in question that runs a script that checks it everytime someone gets into it.

for example in the init line of the vehicle:

this addeventhandler ["GetIn", {[_this select 0, _this select 1, _this select 2] execVM "pilot_check.sqf"}]

and the script (pilot_check.sqf) could look like this:

_veh = _this select 0;

_seat = _this select 1;

_unit = _this select 2;

_pilots = ["pilot_unit_classname1","pilot_unit_classnames2"];

if (!(_seat == "Driver")) exitwith {}; ///this will ensure that people can get in the cargo and gunner position

if ((typeof _unit) in _pilots) then {} else {_unit action ["getout",_veh]};

this is not tested and may contain errors. it's just a quick concept of what you could do.

Share this post


Link to post
Share on other sites

You need to make a loop and see if the player jumped into the pilot seat. Otherwise you can jump "ride in back" and then switch to Pilot since getIn EV's are not triggered when changing seats.

Share this post


Link to post
Share on other sites
Otherwise you can jump "ride in back" and then switch to Pilot since getIn EV's are not triggered when changing seats.

oh i see. makes sense.

Share this post


Link to post
Share on other sites

i've been thinking about this some more and found a way to make it work with event handlers.

now people will only be allowed to board cargo and gunner positions when a pilot is already in the pilot seat. to avoid the seat switching problem cuel mentioned i also added a "getout" event handler that will eject everyone from the vehicle if the pilot ejects. i tested it ingame and it works like a charm.

vehicle init line:

this addeventhandler ["GetIn", {[_this select 0, _this select 1, _this select 2] execVM "pilot_check.sqf"}];

this addeventhandler ["GetOut", {[_this select 0, _this select 1, _this select 2] execVM "pilot_eject_check.sqf"}];

"pilot_check.sqf"

_veh = _this select 0;

_seat = _this select 1;

_unit = _this select 2;

_pilots = ["USMC_Soldier_Pilot"];

if ((typeof _unit) in _pilots) exitwith {};

if (

!((typeof _unit) in _pilots)

&&

((typeof driver _veh) in _pilots)

)

then {} else {_unit action ["getout",_veh]};

"pilot_eject_check.sqf"

_veh = _this select 0;

_seat = _this select 1;

_unit = _this select 2;

if (_seat == "driver") then

{

{

_x action ["GetOut", _veh];

} foreach (crew _veh);

} else {};

Share this post


Link to post
Share on other sites

I wrote a simple FSM file to handle this

https://dl.dropbox.com/u/14106901/pilot_check.rar

init.sqf

[[vehicles],[pilots]] execFSM "pilot_check.fsm";

Parameters can be entered in either class name format or object name, or both

Example:

// Only let pilot1 fly the chinook-type helis
[["CH_47F_EP1"],[pilot1]] execFSM "pilot_check.fsm";

// All units of type pilot can fly chinooks and airplane1/heli1, including unit1 and unit2
[["CH_47F_EP1",airplane1,heli1],["USMC_Soldier_Pilot",unit1,unit2]] execFSM "pilot_check.fsm";

Units not allowed to operate vehicle will be moved into cargo if available, if not, ejected.

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  

×