Jump to content
Sign in to follow this  
Grimfist

Restricted crew set

Recommended Posts

Yo, i am making a mission, and i have come to two barriers that i cant pass, so id thought id post them here. i want a script that checks if the unit is one of the units in an array when boarding a vehicle into the DRIVER, COMMANDER OR GUNNER seats (if there in passenger script is not to run), if they are then nothing happens, if they arnt then they are thrown out of the vehicle. this is what i have:

when any unit boards a vehicle script starts and checks if _unit is not one of the dudes in aray of 'EL, EN1, EN2'

then _soldier action ["eject", vehicle soldier];

display hint 'yo mofo, you cant drive that.'

http://community.bistudio.com/wiki/action

http://community.bistudio.com/wiki/isKindOf

http://community.bistudio.com/wiki/typeOf

http://community.bistudio.com/wiki/driver

http://community.bistudio.com/wiki/lockDriver

http://community.bistudio.com/wiki/assignedDriver

I need some help compiling this, TIA,

grim.

plz can sum1 help, or direct me to some recorces?

Share this post


Link to post
Share on other sites

Wrong place.

this should go in ArmA 2 - MISSION EDITING & SCRIPTING

now.. if i understood you correct. en en1 and en2 is not allowed in driver, gunner or commander. correct ?

My arma 2 isnt beeing friendly with me right now.

i have put up 2 small simple script.

i didnt want to use allowGetIn since it affects all positions afik,

i didnt want to use unassignVehicle since you might be a passenger

1st test

on the car

e = this execvm 'eject.sqf'

eject.sqf

_array=[p1,p2,p3];
while {true} do
{
sleep 1;
{	
	if ((_x in_array) && ((_x == driver vehicle _this) || (_x == gunner vehicle _this) || (_x == commander vehicle _this))) then
	{
		_x action ["getout", vehicle _this]; 
	};
} foreach _array;
};

2nd test

on the car

e = this addEventHandler ["getin", {_this execvm 'eject.sqf'}]

eject.sqf

_array = [p1,p2,p3];
_veh = _this select 0;
_unit = _this select 2;

if ((_unit in _array) && (_unit == driver _veh) || (_unit == gunner _veh) || (_unit == commander _veh)) then
{		
_unit action ["getout", _veh]; 
};

now this seams all ok. but its not,

in the editor i got.

p1 me.

p2 set to playeble. grouped to p1

p3 set to playeble. grouped to p1

if i order the AI p2 or p3 to get in as driver in the HMMWV,

the scripts does exactly what its suppose to do. eject the driver/gunner/commander. ++ much more. it kills the AI after he has ejected. :eek:

i tested this on a Tank "M1A1". there was no issue there, so i guess you can use it as long as its not a HMMWV car. :j:

is there a bug with the HMMWV that i dont know about ?

can anyone confirme this issue. i like to know.

Edited by nuxil

Share this post


Link to post
Share on other sites

do something like this

e = this addEventHandler ["getin", {_this execvm 'eject.sqf'}]

_veh = _this select 0;

_unit = _this select 2;

if (_unit == c17) then

{

{_x action ["getout", _veh];} foreach crew _veh;

};

edit. sorry i dont follow, what is c.-17 .. lol

Edited by nuxil

Share this post


Link to post
Share on other sites

Since I made the effort to move this thread, I'll try to help.

For a specific vehicle, use the GetIn eventhandler. Use this on the vehicle's init line:

dasboot = this addEventHandler ["getin", {_this execvm 'crewcheck.sqf'}]

And use this for crewcheck.sqf:

array = _this;
_vehicle = _this select 0;
_position = _this select 1;
_man = _this select 2;

if (!(_man in crewarray) && _position != "cargo") then
{
hint format ["Hey %1, you asshat, you can't sit there",name _man];
_man action ["eject",_vehicle];
};

Where "crewarray" is your array of allowed vehicle crew.

Share this post


Link to post
Share on other sites

Hey Franze

basicly same code but much better looking :p

but i think you meant.

if ((_man in crewarray) && _position != "cargo") then

but does your AI die if you test this on a HMMWV ?

my AI dies after the eject

Share this post


Link to post
Share on other sites
Hey Franze

basicly same code but much better looking :p

but i think you meant.

if ((_man in crewarray) && _position != "cargo") then

but does your AI die if you test this on a HMMWV ?

my AI dies after the eject

If I read the original question right, he has a defined array of allowed crewmen, and anyone not in that array is prohibited crew entry. It's easy to reverse it though, as you noted.

And yes, my AI bites the dust, both with "getout" and "eject". Strange behavior; I tried setpos instead, but that results in some odd stuff for the player. Perhaps I'll file this away as a unique and complex way to waste annoying AIs in my team. ;)

Share this post


Link to post
Share on other sites

ahh ty guys, really ty, ill put this it now and test it.

and yes franze is right, they can crew only if in my array.

EDIT: it works great but you can ride in back and 'change to gunner' so would put:

dasboot = this addEventHandler ["getin", {_this execvm 'crewcheck.sqf'}]; dasboot = this addEventHandler ["SWITCHPOSITION", {_this execvm 'crewcheck.sqf'}];

or summin?

Edited by Grimfist

Share this post


Link to post
Share on other sites

There isn't a "switchedposition" eventhandler; you'll need a looping script to continuously check the status of the crew.

In vehicle init:

vehsitrep = [this] execvm "crewsitrep.sqf"

crewsitrep.sqf

_vehicle = _this select 0;
_driver = driver _vehicle;
_gunner = gunner _vehicle;
_commander = commander _vehicle;

while {alive _vehicle} do
{
_driver = driver _vehicle;
_gunner = gunner _vehicle;
_commander = commander _vehicle;

if (!(_driver in crewarray) && !(isNull _driver)) then
{
hint format ["Hey %1, who the hell do you think you are? Get back there before I kick your ass",name _driver];
_driver action ["getout",_vehicle];
};
if (!(_gunner in crewarray) && !(isNull _gunner)) then
{
hint format ["Hey %1, who the hell do you think you are? Get back there before I kick your ass",name _gunner];
_gunner action ["getout",_vehicle];
};
if (!(_commander in crewarray) && !(isNull _commander)) then
{
hint format ["Hey %1, who the hell do you think you are? Get back there before I kick your ass",name _commander];
_commander action ["getout",_vehicle];
};
sleep 1
};

Note that this is only for the three main crew positions; if you have any additional gunners on the vehicle, you'll need something more complex than the above.

Share this post


Link to post
Share on other sites

WOW, ty m8.

will that add to lag at all though, becuase thats the main focus of my mission?

Share this post


Link to post
Share on other sites
will that add to lag at all though, becuase thats the main focus of my mission?

Your main focus of the mission is to add lag? :D

Just kidding, with the 1 second sleep it won't have much (if any) effect :)

Share this post


Link to post
Share on other sites

lol ty, i meant to lessen lag.

(im making a AAS with minim scripts and stuff)

Share this post


Link to post
Share on other sites
do something like this

e = this addEventHandler ["getin", {_this execvm 'eject.sqf'}]

edit. sorry i dont follow, what is c.-17 .. lol

The C-17 is the big Cargo Plane, is that the script for it?

Share this post


Link to post
Share on other sites

Well, its not working, its throwing everyone out of the vehicle, even the people in the array.

@ Sgt Cresswell its not, its a c130 ;)

Share this post


Link to post
Share on other sites

Oh yeah, sorry, what's the script to make people in the cargo eject, but not the pilot.

I like the way in your avatar it has "No" highlighted lol.

Edited by Sgt Cresswell

Share this post


Link to post
Share on other sites
Well, its not working, its throwing everyone out of the vehicle, even the people in the array.

That's odd, it worked when I tested it. Is the array named correctly?

Share this post


Link to post
Share on other sites

wait wait wait... the script is great but I need this for M1A2 Too... I'm using the second one! Thanks...

EDIT: I find a solution:

/////////////////////////////////////////////////////////////////////////////////////////////////

//

// SCRIPT CREATED BY LUPO V 1.0

//

/////////////////////////////////////////////////////////////////////////////////////////////////

//

// UNITS RESTRICTED ACCESS TO VEHICLES

//

// put this file into "scripts" folder in your mission folder.

//

// call it from every unit init field with:

//

// this addEventHandler ["getin", {v = _this execVM "Scripts\VehiClassLim.sqf"}]

//

//

// You can edit vehicle access by editing the "vehicle types" and "crew types" array.

// Some restriction are a little redoundant with basic ArmA units, but they make sense

// if you use addons which provide several crew types or want to restrict access to particular

// types of soldiers.

//

// use this script at your own risk I take no responsibility for any problem due to the use of it

//

//

//////////////////////////////////////////////////////////////////////////////////////////////////

// -----Defining vehicle types-----

_fighter = ["F35B", "Su34"];

_bomber = ["A10", "AV8B", "AV8B2", "Su25_CDF", "SU25_Ins", "SU39"];

_cargoplane = ["C130J"];

_attackheli = ["AH1Z", "Mi24_D", "Mi24_P", "Mi24_V", "Ka52", "Ka52Black"];

_utilityheli = ["Mi17_CDF", "Mi17_Civilian", "Mi17_Ins", "Mi17_medevac_CDF", "Mi17_medevac_Ins", "Mi17_medevac_RU", "Mi17_rockets_RU", "MH60S", "MV22", "UH1Y"];

_tank = ["M1A1", "M1A2_TUSK_MG", "T34", "T72_CDF", "T72_Gue", "T72_INS", "T72_RU", "T90"];

_apc = ["BMP2_CDF", "BMP2_Gue", "BMP2_INS", "BMP3", "AAV"];

_ifv = ["BRDM2_ATGM_CDF", "BRDM2_ATGM_INS","BRDM2_CDF","BRDM2_Gue","BRDM2_INS", "BTR90", "LAV25"];

_support = ["BMP2_Ambul_CDF", "BMP2_Ambul_Ins", "GAZ_Vodnik_MedEvac", "HMMWV_Ambulance", "KamazReammo", "KamazRefuel", "KamazRepair", "MtvrReammo", "MtvrRefuel", "MtvrRepair", "UralReammo_CDF", "UralRefuel_CDF", "UralRepair_CDF", "UralReammo_INS", "UralRefuel_INS", "UralRepair_INS"];

_airdefence = ["2S6M_Tunguska", "ZSU_CDF", "ZSU_INS", "HMMWV_Avenger", "Ural_ZU23_CDF", "Ural_ZU23_Gue", "Ural_ZU23_INS"];

_car = ["HMMWV", "HMMWV_Armored", "HMMWV_M2", "HMMWV_MK19", "HMMWV_TOW", "Kamaz", "KamazOpen", "MTVR", "UAZ_AGS30_CDF", "UAZ_AGS30_INS", "UAZ_AGS30_RU", "UAZ_CDF", "UAZ_INS", "UAZ_MG_CDF", "UAZ_MG_INS", "UAZ_RU", "UAZ_SPG9_INS", "GAZ_Vodnik", "GAZ_Vodnik_HMG", "UralOpen_CDF", "Ural_CDF", "UralOpen_INS", "Ural_INS", "V3S_Gue"];

_ship = ["RHIB", "RHIB2Turret", "PBX", "Zodiac"];

_command = ["BMP2_HQ_CDF", "BMP2_HQ_INS", "BRDM2_HQ_Gue", "BTR90_HQ", "LAV25_HQ"];

_artillery = ["MLRS", "GRAD_CDF", "GRAD_INS", "GRAD_RU"];

// -----Defining crew types-----

_fighterpilot = ["CDF_Soldier_Pilot", "Ins_Soldier_Pilot", "GUE_Soldier_Pilot", "USMC_Soldier_Pilot", "RU_Soldier_Pilot"];

_bomberpilot = ["CDF_Soldier_Pilot", "Ins_Soldier_Pilot", "GUE_Soldier_Pilot", "USMC_Soldier_Pilot", "RU_Soldier_Pilot"];

_cargoplanepilot = ["CDF_Soldier_Pilot", "Ins_Soldier_Pilot", "GUE_Soldier_Pilot", "USMC_Soldier_Pilot", "RU_Soldier_Pilot"];

_attackhelipilot = ["CDF_Soldier_Pilot", "Ins_Soldier_Pilot", "GUE_Soldier_Pilot", "USMC_Soldier_Pilot", "RU_Soldier_Pilot"];

_utilityhelipilot = ["CDF_Soldier_Pilot", "Ins_Soldier_Pilot", "GUE_Soldier_Pilot", "USMC_Soldier_Pilot", "RU_Soldier_Pilot"];

_tankcrew = ["CDF_Soldier_Crew", "Ins_Soldier_Crew", "GUE_Soldier_Crew", "USMC_Soldier_Crew", "RU_Soldier_Crew"];

_apccrew = ["CDF_Soldier_Crew", "Ins_Soldier_Crew", "GUE_Soldier_Crew", "USMC_Soldier_Crew", "RU_Soldier_Crew"];

_ifvcrew = ["CDF_Soldier_Crew", "Ins_Soldier_Crew", "GUE_Soldier_Crew", "USMC_Soldier_Crew", "RU_Soldier_Crew"];

_supportcrew = ["CDF_Soldier_Crew", "Ins_Soldier_Crew", "GUE_Soldier_Crew", "USMC_Soldier_Crew", "RU_Soldier_Crew", "RU_Soldier_SniperH", "RU_Soldier_Spotter", "RU_Commander", "RU_Soldier_Pilot", "RU_Soldier_HAT", "RU_Soldier_AT", "RU_Soldier_SL", "RU_Soldier_AA", "RU_Soldier_MG", "RU_Soldier_LAT", "RU_Soldier_GL", "RU_Soldier_Marksman", "RU_Soldier_AR", "RU_Soldier", "RUS_Soldier2", "RUS_Soldier_Marksman", "RU_Soldier_Medic", "USMC_Soldier_SL", "USMC_Soldier_TL", "USMC_Soldier_AR", "USMC_Soldier_LAT", "USMC_Soldier", "USMC_SoldierS_SniperH", "USMC_SoldierS_Spotter", "FR_R", "FR_Marksman", "USMC_Soldier_Officer", "USMC_Soldier_Pilot", "USMC_Soldier_Medic", "USMC_Soldier_HAT", "USMC_Soldier_AT", "USMC_Soldier_AA"];

_airdefencecrew = ["CDF_Soldier_Crew", "Ins_Soldier_Crew", "GUE_Soldier_Crew", "USMC_Soldier_Crew", "RU_Soldier_Crew"];

_carcrew = ["CDF_Soldier_Crew", "Ins_Soldier_Crew", "GUE_Soldier_Crew", "USMC_Soldier_Crew", "RU_Soldier_Crew", "RU_Soldier_SniperH", "RU_Soldier_Spotter", "RU_Commander", "RU_Soldier_Pilot", "RU_Soldier_HAT", "RU_Soldier_AT", "RU_Soldier_SL", "RU_Soldier_AA", "RU_Soldier_MG", "RU_Soldier_LAT", "RU_Soldier_GL", "RU_Soldier_Marksman", "RU_Soldier_AR", "RU_Soldier", "RUS_Soldier2", "RUS_Soldier_Marksman", "RU_Soldier_Medic", "USMC_Soldier_SL", "USMC_Soldier_TL", "USMC_Soldier_AR", "USMC_Soldier_LAT", "USMC_Soldier", "USMC_SoldierS_SniperH", "USMC_SoldierS_Spotter", "FR_R", "FR_Marksman", "USMC_Soldier_Officer", "USMC_Soldier_Pilot", "USMC_Soldier_Medic", "USMC_Soldier_HAT", "USMC_Soldier_AT", "USMC_Soldier_AA"];

_shipcrew = ["CDF_Soldier_Light", "Ins_Soldier_Crew", "GUE_Soldier_Crew", "USMC_Soldier_Light", "RU_Soldier_Light", "USMC_LHD_Crew_Blue", "USMC_LHD_Crew_Brown", "USMC_LHD_Crew_Green", "USMC_LHD_Crew_Purple", "USMC_LHD_Crew_Red", "USMC_LHD_Crew_White", "USMC_LHD_Crew_Yellow"];

_commandcrew = ["CDF_Soldier_Officer", "Ins_Commander", "GUE_Commander", "FR_Commander", "USMC_Soldier_Officer", "MVD_Soldier_TL", "RUS_Commander", "RU_Commander"];

_artillerycrew = ["CDF_Soldier_Light", "Ins_Soldier_Crew", "GUE_Soldier_Crew", "USMC_Soldier_Light", "RU_Soldier_Light", "FR_AC", "Spetsnaz Scout"];

//////////////////////////////////////////////////////////////////////////////

//

//DON'T EDIT BELOW THIS POINT IF YOU DON'T KNOW WHAT YOU ARE DOING!!!!!!

//

//////////////////////////////////////////////////////////////////////////////

_veh = _this select 0;

_pos = _this select 1;

_unit = _this select 2;

_unittype = typeof _unit;

_vehtype = typeof _veh;

_crew = [];

// -----Setting crew types-----

if (_vehtype in _fighter) then { _crew = _fighterpilot;};

if (_vehtype in _bomber) then { _crew = _bomberpilot;};

if (_vehtype in _attackheli) then { _crew = _cargoplanepilot;};

if (_vehtype in _utilityheli) then { _crew = _attackhelipilot;};

if (_vehtype in _cargoplane) then { _crew = _utilityhelipilot;};

if (_vehtype in _tank) then { _crew = _tankcrew ;};

if (_vehtype in _apc) then { _crew = _apccrew ;};

if (_vehtype in _ifv) then { _crew = _ifvcrew;};

if (_vehtype in _support) then { _crew = _supportcrew;};

if (_vehtype in _airdefence) then {_crew = _airdefencecrew;};

if (_vehtype in _car) then { _crew = _carcrew;};

if (_vehtype in _ship) then { _crew = _shipcrew;};

if (_vehtype in _command) then { _crew = _commandcrew;};

if (_vehtype in _artillery) then { _crew = _artillerycrew;};

// -----Checking crew -----

if (!(_unittype in _crew)) then

{

if (_pos != "cargo") then

{

unassignvehicle _unit;

_unit action ["eject", _veh];

}

else

{

while {vehicle _unit == _veh} do

{

sleep 0.5;

if ((commander _veh == _unit) or (driver _veh == _unit) or (gunner _veh == _unit)) then

{

_unit action ["moveToCargo", _veh, 0];

};

};

};

};

Thank you!

Edited by M3th0s

Share this post


Link to post
Share on other sites

here is your script:

// to activate: vehsitrep = [this] execvm "crewsitrep.sqf"

_vehicle = _this select 0;
_driver = driver _vehicle;
_gunner = gunner _vehicle;
_commander = commander _vehicle;

while {alive _vehicle} do 
{
_driver = driver _vehicle;
_gunner = gunner _vehicle;
_commander = commander _vehicle;

if (!(_driver in  [e1,e2,e3,e4,e5,e6]) && !(isNull _driver)) then
{
hint format ["Hey %1, you asshat, only engineers can crew vehicles.",name _driver];
_driver action ["getout",_vehicle];
};
if (!(_gunner in  [e1,e2,e3,e4,e5,e6]) && !(isNull _gunner)) then
{
hint format ["Hey %1, you asshat, only engineers can crew vehicles.",name _gunner];
_gunner action ["getout",_vehicle];
};
if (!(_commander in  [e1,e2,e3,e4,e5,e6]) && !(isNull _commander)) then
{
hint format ["Hey %1, you asshat, only engineers can crew vehicles.",name _commander];
_commander action ["getout",_vehicle];
};
sleep 1
};

my men are e1, e2, e3, e4, e5, and e6. i don't understand?

Share this post


Link to post
Share on other sites

Try defining your array:

crewarray = [e1,e2,e3,e4,e5,e6]

Then use crewarray in place of the actual array.

It works either way for me, so the only thing I can think of is there's a glitch somewhere in the array or the unit names.

Share this post


Link to post
Share on other sites
TY, but how would tht fit it?

I'm not exactly sure, but I'm out of ideas. By defining the array and using crewarray it makes it easier to track the units in the array.

I'd suggest this: crewarray = [mydude]

Create a LAV-25 and have it run an instance of my original script.

Then place a soldier on the map and call him mydude - then either make him the player or playable, switch to him, and try to get into the LAV-25's crew seats. If it still doesn't work, then something else is going on.

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  

×