Jump to content
Sign in to follow this  
Diabolical1001

Define Unit by Clothing

Recommended Posts

Hello everyone

I dont know if this is a quick fix or just impossible

Iam using a script that will only let pilot class soldiers enter helo's/plane's

in a game mode iam working on the class selection interface im using will only change your outfit not your actual unit class (rifleman in pilot clothing)

this is the code by Sa-Matra

true spawn {

//List of pilot classes, crewman classes, affected aircraft classes and affected vehicle classes

_pilots = ["B_Helipilot_F"];

_crewmen = ["B_crew_F"];

_aircraft = ["O_Heli_Attack_02_black_F","B_Heli_Light_01_armed_F","B_Heli_Light_01_F","I_Heli_Transport_02_F","B_Heli_Transport_01_F","B_Heli_Transport_01_camo_F","I_Plane_Fighter_03_CAS_F"];

_armor = ["B_APC_Wheeled_01_cannon_F","B_APC_Tracked_01_CRV_F","B_MBT_01_cannon_F","B_MBT_01_arty_F","I_APC_Wheeled_03_cannon_F"];

//Wait until player is fully loaded

waitUntil {player == player};

//Check if player is pilot or crewman, you can add more classes into arrays

_iampilot = ({typeOf player == _x} count _pilots) > 0;

_iamcrewman = ({typeOf player == _x} count _crewmen) > 0;

//Never ending cycle

while{true} do {

//Wait until player's vehicle changed

_oldvehicle = vehicle player;

waitUntil {vehicle player != _oldvehicle};

//If player is inside vehicle and not on foot

if(vehicle player != player) then {

_veh = vehicle player;

//Check if vehicle is aircraft and player is not pilot

if(({typeOf _veh == _x} count _aircraft) > 0 && !_iampilot) then {

//Forbidden seats: copilot, gunner, pilot

_forbidden = [_veh turretUnit [0]] + [gunner _veh] + [driver _veh];

if(player in _forbidden) then {

hint "YOU ARE NOT A PILOT! get outta here, dont bother trying co-pilot either";

player action ["eject", _veh];

};

};

//Check if vehicle is armor and player is not crewman

if(({typeOf _veh == _x} count _armor) > 0 && !_iamcrewman) then {

//Forbidden seats: gunner, driver

_forbidden = [gunner _veh] + [driver _veh];

if(player in _forbidden) then {

systemChat "YOU ARE NOT A CREWMAN! get outta here, dont try the gun either";

player action ["eject", _veh];

};

};

};

};

};

so were it defines _pilots = ["B_Helipilot_F"];

would there be a way to make it read a combination of clothing instead? "H_pilothelmetfighter_B" , "U_B_pilotcoveralls" , "B_parachute";

thanks in advance

Edited by Diabolical1001

Share this post


Link to post
Share on other sites

You would basically need to re-write the script to work with clothing. Maybe not a full re-write, but by the time you figure it out you may aswell write a fresh script that does exactly what you want. At any rate, you can check for clothing (uniform) like:

Something like this:

if (uniform player != "pilot_uniform_name" && {driver theHelo == player}) then { 
     player action ["eject", theHelo];
};

Tip: Use code brackets, not quotes to post scripts/code. It makes it alot easier to read == more/better responses.

Edited by Iceman77

Share this post


Link to post
Share on other sites

Tip: Use code brackets, not quotes to post scripts/code. It makes it alot easier to read == more/better responses.

if (uniform player != "pilot_uniform_name" && {driver theHelo == player}) then { 
     player action ["eject", theHelo];
};

Tip: Use php brackets, not code to post scripts/code. It makes it alot easier to read == more/better responses

if (uniform player != "pilot_uniform_name" && {driver theHelo == player}) then { 
     player action ["eject", theHelo];
};

Share this post


Link to post
Share on other sites
You would basically need to re-write the script to work with clothing. Maybe not a full re-write, but by the time you figure it out you may aswell write a fresh script that does exactly what you want. At any rate, you can check for clothing (uniform) like:

Something like this:

if (uniform player != "pilot_uniform_name" && {driver theHelo == player}) then { 
     player action ["eject", theHelo];
};

Tip: Use code brackets, not quotes to post scripts/code. It makes it alot easier to read == more/better responses.

Tip: Use php brackets, not code to post scripts/code. It makes it alot easier to read == more/better responses

if (uniform player != "pilot_uniform_name" && {driver theHelo == player}) then { 
     player action ["eject", theHelo];
};

I don't see the need for the sarcastic mockery. I was simply giving the guy a tip (very subtly & nicely) to not post code using quotes... use php or code brackets.. either are 100x easier to read than quotes :confused:

You could have simply explained why syntax highlighting is, how it works, and why it's so terribly important... instead of mocking me :)

Edited by Iceman77
I highly doubt someone will turn away from a post because the code isn't colored / highlighted... haha fml

Share this post


Link to post
Share on other sites

i assume if im correct that were it states {driver theHelo == player})

theHelo = the name of the the aircraft not the class?. there you go, you can use sarcasm on my newbie questions. just here to learn

Share this post


Link to post
Share on other sites
You would basically need to re-write the script to work with clothing. Maybe not a full re-write, but by the time you figure it out you may aswell write a fresh script that does exactly what you want. At any rate, you can check for clothing (uniform) like:

Something like this:

if (uniform player != "pilot_uniform_name" && {driver theHelo == player}) then { 
     player action ["eject", theHelo];
};

Tip: Use code brackets, not quotes to post scripts/code. It makes it alot easier to read == more/better responses.

so say i wanted to make this work with class names would i go

_aircraft = ["heloclassname"];

waitUntil {player == player};

if (uniform player != "pilot_uniform_name" && {driver _aircraft == player}) then { 
     player action ["eject", _aircraft];
};

as ive said, pretty fresh to all of this

Share this post


Link to post
Share on other sites

Maybe try something like this:

waitUntil {!isNull player};
_aircraft = ["B_Heli_Light_01_F"];

while {true} do {
   if (uniform player != "U_B_PilotCoveralls" && {driver vehicle player == player} && {typeOf vehicle player in _aircraft}) then { 
       player action ["eject", vehicle player];
   };
sleep 1;
};	

You could also use a getIn eventhandler, but then the player can get into the cargo area and then into the drivers seat without getting kicked.

---------- Post added at 18:17 ---------- Previous post was at 18:08 ----------

updated again

Edited by Iceman77
added typeOf

Share this post


Link to post
Share on other sites
I hear that. Me too.

Maybe try something like this:

_aircraft = ["B_Heli_Light_01_F"];
waitUntil {!isNull player};
while {true} do {
   if (uniform player != "U_B_PilotCoveralls" && {driver vehicle player == player} && {typeOf vehicle player in _aircraft}) then { 
       player action ["eject", vehicle player];
   };
sleep 1;
};	

You could also use a getIn eventhandler, but then the player can move into the cargo area and then into the drivers seat without getting kicked.

---------- Post added at 18:17 ---------- Previous post was at 18:08 ----------

updated again

ok. hopefully my last question before i test this fully

were it states (uniform player != "U_B_PilotCoveralls" does that only define the clothing of the player or can it also be use to define lets say a helmet of a player?

Edited by Diabolical1001

Share this post


Link to post
Share on other sites

That defines the uniform the player must wear to pilot the aircraft. You could define a helmet (headGear) instead. Or both as a requirement. Or one or the other as a requirement.

headgear check:

waitUntil {!isNull player};
_aircraft = ["B_Heli_Light_01_F"];

while {true} do {
   if (headGear player != "H_PilotHelmetFighter_B" && {driver vehicle player == player} && {typeOf vehicle player in _aircraft}) then { 
       player action ["eject", vehicle player];
   };
sleep 1;
};	

both:

waitUntil {!isNull player};
_aircraft = ["B_Heli_Light_01_F"];

while {true} do {
   if (driver vehicle player == player && {typeOf vehicle player in _aircraft}) then { 
        if (headGear player != "H_PilotHelmetFighter_B" || {uniform player != "U_B_PilotCoveralls"}) then { 
             player action ["eject", vehicle player];
        };
   };
 sleep 1;
};


both again:

waitUntil {!isNull player};
_aircraft = ["B_Heli_Light_01_F"];

while {true} do {
   if ((uniform player != "U_B_PilotCoveralls" || {headGear player != "H_PilotHelmetFighter_B"}) && {driver vehicle player == player} && {typeOf vehicle player in _aircraft}) then { 
       player action ["eject", vehicle player];
   };
sleep 1;
};	

one or the other:

waitUntil {!isNull player};
_aircraft = ["B_Heli_Light_01_F"];

while {true} do {
   if (uniform player != "U_B_PilotCoveralls" && {headGear player != "H_PilotHelmetFighter_B"} && {driver vehicle player == player} && {typeOf vehicle player in _aircraft}) then { 
       player action ["eject", vehicle player];
   };
sleep 1;
};	

Edited by Iceman77

Share this post


Link to post
Share on other sites
I don't see the need for the sarcastic mockery. I was simply giving the guy a tip (very subtly & nicely) to not post code using quotes... use php or code brackets.. either are 100x easier to read than quotes :confused:

You could have simply explained why syntax highlighting is, how it works, and why it's so terribly important... instead of mocking me :)

I wasn't mocking you, I was correcting you...

Only trying to help.

Edited by Beerkan

Share this post


Link to post
Share on other sites
I wasn't mocking you, I was correcting you...

Only trying to help.

Oh Okay... It came across as a snide attempt at mockery :rolleyes:. In any case, thanks for the tips. Cheers.

---------- Post added at 19:29 ---------- Previous post was at 18:59 ----------

Could use getIn eventhandler too. Passed array: [vehicle, position, unit] You'd need to add the eventhandler to every newly created aircraft aswell. Note, players can possibly exploit this method by hopping in the copilot seat and taking control, so you may want to use the previous methods. However, this works very well for land vehicles.

vehicle init line (editor placed):

this addEventHandler ["getIn", {[(_this select 2)] spawn TAG_fnc_eject}];

newly created vehicle example

_veh = createVehicle ["B_Heli_Light_01_F", getPos somePos , [], 0, "CAN_COLLIDE"];
_veh addEventHandler ["getIn", {[(_this select 2)] spawn TAG_fnc_eject}];

init.sqf

TAG_fnc_eject = {

  _unit = _this select 0;

   waitUntil {driver vehicle _unit == _unit || {vehicle _unit == _unit} || {!alive _unit}};
       if (vehicle _unit != _unit && {uniform _unit != "U_B_PilotCoveralls" || {headGear _unit != "H_PilotHelmetFighter_B"}}) then {
           _unit action ["eject", vehicle _unit];
       };
};

---------- Post added at 21:23 ---------- Previous post was at 19:29 ----------

Changed the (EH) eject function a bit.

Edited by Iceman77

Share this post


Link to post
Share on other sites

There you go. Post any additional / revised code for others to see :)

Edited by Iceman77

Share this post


Link to post
Share on other sites

Sorry just got to thinking... were you asking for help to include the turret or telling that you've added it? In any case:

//init.sqf

TAG_fnc_eject = {

   _unit = _this select 0;

   waitUntil {driver vehicle _unit == _unit || {_unit in [vehicle _unit turretUnit [0]]} || {vehicle _unit == _unit} || {!alive _unit}};
       if (vehicle _unit != _unit && {uniform _unit != "U_B_PilotCoveralls" || {headGear _unit != "H_PilotHelmetFighter_B"}}) then {
           _unit action ["eject", vehicle _unit];
       };
};  

//this addEventHandler ["getIn", {[(_this select 2)] spawn TAG_fnc_eject}];

Edited by Iceman77

Share this post


Link to post
Share on other sites

ok the pilot side of things are working, i decided i didnt want to use an eventhandler. so i ended up using the older code you had put up

waitUntil {!isNull player};
_aircraft = ["B_Heli_Light_01_F"];

while {true} do {
   if (driver vehicle player == player && {typeOf vehicle player in _aircraft}) then { 
        if (headGear player != "H_PilotHelmetFighter_B" || {uniform player != "U_B_PilotCoveralls"}) then { 
             player action ["eject", vehicle player];
        };
   };
 sleep 1;
}; 

now i want to move onto the vehicles (apc's, tanks, etc) and also, i dont know how to implement the turret restriction with this one?

Share this post


Link to post
Share on other sites

The EH method I posted is much cleaner though :eek:. In any case, should be same method as earlier we used to impliment the turret.

waitUntil {!isNull player};
_armor = ["B_MBT_01_cannon_F"];

while {true} do {
   if (typeOf vehicle player in _armor && {driver vehicle player == player || {player in [vehicle player turretUnit [0]]} || {player in [vehicle player turretUnit [0,0]]}}) then { 
        if (headGear player != "H_HelmetCrew_B" || {uniform player != "U_B_CombatUniform_mcam_vest"}) then { 
             player action ["eject", vehicle player];
        };
   };
 sleep 1;
};  

You can look here for the different turrets. [0,0] is the commander.

--------------------------------------------------------------------------

EH method example. No loops (waitUntil, or while etc etc), much better imo :cool:

this addEventHandler ["getIn", {call TAG_fnc_eject}]; 

TAG_fnc_eject = {

   _unit = _this select 2;

   if (vehicle _unit isKindOf "Tank" && {driver vehicle _unit == _unit || {_unit in [vehicle _unit turretUnit [0]]} || {_unit in [vehicle _unit turretUnit [0,0]]}}) then { 
       if (headGear _unit != "H_HelmetCrew_B" || {uniform _unit != "U_B_CombatUniform_mcam_vest"}) then { 
           _unit action ["eject", vehicle _unit];
       };
   };
};  

Edited by Iceman77

Share this post


Link to post
Share on other sites

Sorry, don't really need to check for "Tank" kind as you'd be assigning specific vehicles the EH. But w/e. It's in there, you can take that part out if you wish.

Share this post


Link to post
Share on other sites
Sorry, don't really need to check for "Tank" kind as you'd be assigning specific vehicles the EH. But w/e. It's in there, you can take that part out if you wish.

how about performance wise, it will be going into a large scale tvt gamemode

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  

×