Jump to content
wolkenbeisser

Check if player is in a specific turret

Recommended Posts

Hi everybody

 

In a trigger I have the following condition:

 

vehicle player isKindOf "Helicopter" and (
(driver (vehicle player)) isEqualTo player or
(gunner (vehicle player)) isEqualTo player or
(commander (vehicle player)) isEqualTo player
)

 

With this I would like to check if the player is the driver/gunner/commander of the helicopter he just entered and can give him another headgear (a helmet for example). The reason I do this is because I don't want the player to have another headgear when he enters into a cargo space.

 

Now the problem is: It works great for driver and gunner, but the commander doesn't work, as he sits in a turret. So I'm now looking for a way to replace the term "commander" with a code that checks the turret. Something like this:

 

([vehicle player turret, [0]] (vehicle player)) isEqualTo player

Sorry if the question looks stupid. I'm not a programmer and therefore have almost no knowlege about code. I googled for an hour now with "Arma 3 check if unit is in a specific turret" (and with similar search words) but I couldn't find anything that solves my problem - or maybe I didn't understand it.

 

So thanks everybody for your help and kind regards

Wolkenbeisser

  • Like 1

Share this post


Link to post
Share on other sites

the command fullCrew is able to give u the information about who is in which seat of a vehicle.

Share this post


Link to post
Share on other sites

Thanks for your reply sarogahtyp

 

But, that's not exactly what I need (except I miss the meaning of fullCrew somehow). I already know who is in the vehicle. --> It's always the player (who is a local thing on each client I guess).

 

By the way 1: The code will be used for a MP-mission.

By the way 2: Another great thing would be if I could somehow save the headgear the player has before replacing it. Because with that I could give it back to him as soon as he leaves the chopper (within the "onDeact" field of the trigger). But I don't think that this is possible, so I would already be happy with the answer to my original question.

 

Thanks guys.

 

 

Share this post


Link to post
Share on other sites

trust me. fullCrew is exactly what u could use!

just compare ur player object with the first elements of all nested arrays, compare also if its seat has turret role and if it is not an FFV seat (last element of the nested arrays)

Share this post


Link to post
Share on other sites

Thanks killzone

 

Code of the condition field of the trigger now looks like this:

vehicle player isKindOf "Helicopter" and ( 
(driver (vehicle player)) isEqualTo player or 
(gunner (vehicle player)) isEqualTo player or 
(vehicle player turretUnit turret, [0]] == player) 
)

But it still doesn't work. I can't even klick the OK-button of the trigger. I imagined that I had to leave the "if" and the "then", as they are already represented by the condition field and the on activation field of the trigger. But even leaving these I stil get an error message. It says missing ")" which is not correct (all the brackets match perfectly).

 

@ sarogathtyp: Thanks for your reply too, but I have no idea how I can compare the player object with the first elements of all nested array... that really sounds like chinese to me (as I said, I have no idea about programming, so... I'm really lost with that requirement).

Share this post


Link to post
Share on other sites

vehicle player isKindOf "helicopter" && assignedVehicleRole player select 0 != "cargo"

 

This way you will detect any place not in cargo, so for crew (pilot,copilot,gunners,load master...)

Share this post


Link to post
Share on other sites
12 hours ago, wolkenbeisser said:

But it still doesn't work

Why would it? You have syntax error, look up wiki for correct usage of turretUnit

Share this post


Link to post
Share on other sites
_vec = objectParent player;
_seats = fullcrew [_vec, "", false];
_index = _seats findIf {(_x select 0) isEqualTo player && {!(toLower (_x select 1) isEqualTo "cargo" || ( toLower (_x select 1) isEqualTo "turret" && (_x select 4) isEqualTo true ))}};
(isKindOf "Helicopter" && _index > -1)

not tested but should check if player is not in cargo seat or in a FFV turret (Fire From Vehicle).

FFV turrets are cargo seats where the unit can shoot with it's own gun from.

The special thing of these seats is that they have not the "cargo" role but the "turret" role and are flagged true with the last element of the nested arrays returned by fullCrew command.

looks odd but should be the thing you need. Idk if @pierremgis mentioned assignedVehicleRole command returns those FFV seats as cargo. if that is the case then I would prefer his solution but if assignedVehicleRole returns "Turret" for Cargo FFV seats then I would prefer fullCrew.

Share this post


Link to post
Share on other sites

Thanks everybody!

 

Problem solved. All provided solutions work now. 🙂👍

 

The only thing left for me now is to find out which solution fits best for my scenario.

 

Btw. @ killzone_kid: Got the syntax for turretUnit corrected now. So my example would look like this (here the turret of the copilot "[0]" is included):

vehicle player isKindOf "Helicopter" and 
(
(driver (vehicle player)) isEqualTo player or 
(gunner (vehicle player)) isEqualTo player or 
(vehicle player turretUnit [0] == player) 
)

 

 

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

×