Jump to content
Sign in to follow this  
CapBlackShot

How can a trigger detect if a player is in a vehicle?

Recommended Posts

Hello,

I'm trying to add a trigger that only opens the bargate when there is a pearson on the selected area. I already have the open/close bargate code, I just need to know that.

Could anyone help me? I tried to search a lot on the internet, but I don't find exactly what I want.

Thank you!

Share this post


Link to post
Share on other sites

try this in the activation field:

vehicle player in thislist

Will work if the player is in the trigger area, with or without vehicle, works in both cases.

Share this post


Link to post
Share on other sites

With vehicle detection: vehicle player != player && this, trigger condition = blufor present

Share this post


Link to post
Share on other sites

Thank you, people! Anyway, I managed to find a solution:

{_x iskindof "LandVehicle"} count thislist > 0

:)

Edited by CapBlackShot
  • Thanks 1

Share this post


Link to post
Share on other sites

That would also trigger for AI units

you could add isPlayer _x

  • Thanks 1

Share this post


Link to post
Share on other sites

Anyone knows a working check that works on dedicated servers and checks if a group or all players are in a vehicle ?

Share this post


Link to post
Share on other sites
Anyone knows a working check that works on dedicated servers and checks if a group or all players are in a vehicle ?

Just use the vehicle command and check that the returned value is not equal to the unit the command is being used on.

Here's an example that will check if every playable unit is in a vehicle

_inVehicleCount = {(vehicle _x) != _x} count playableUnits;
if (_inVehicleCount = (count playableUnits) then {true}

Share this post


Link to post
Share on other sites
On 2014-6-21 at 1:21 PM, silentspike said:

Just use the vehicle command and check that the returned value is not equal to the unit the command is being used on.

Here's an example that will check if every playable unit is in a vehicle

 


_inVehicleCount = {(vehicle _x) != _x} count playableUnits;
if (_inVehicleCount = (count playableUnits) then {true}
 

 

it does not work, it gives an error.

Share this post


Link to post
Share on other sites
21 minutes ago, cc_kronus said:

it does not work, it gives an error.

Why only go half the distance? Post the error you get and the attempt you made.

Digging up 3 year old threads twice a day and just posting "does not work" does not help.

 

Cheers

Share this post


Link to post
Share on other sites

Oh my, that is an old post of mine. It's missing a bracket and an equals sign, that's probably why it errors. I assume it was just hastily written as an example anyway as it also has a totally redundant if statement.

Share this post


Link to post
Share on other sites
5 hours ago, silentspike said:

Oh my, that is an old post of mine. It's missing a bracket and an equals sign, that's probably why it errors. I assume it was just hastily written as an example anyway as it also has a totally redundant if statement.

 

Your code doesn't work in SP (0 = 0 because count playableUnits = 0, always), and wait for all players in a vehicle in MP...

 

If the aim is to raise a bar gate when a player (anyone) is in the trigger area and inside a vehicle, a working code for a repeatable trigger none none:

({!isNull objectParent _x && _x inArea thistrigger} count allPlayers) >0

 

Share this post


Link to post
Share on other sites
16 hours ago, pierremgi said:

 

Your code doesn't work in SP (0 = 0 because count playableUnits = 0, always), and wait for all players in a vehicle in MP...

 

If the aim is to raise a bar gate when a player (anyone) is in the trigger area and inside a vehicle, a working code for a repeatable trigger none none:

({!isNull objectParent _x && _x inArea thistrigger} count allPlayers) >0

 

 

Well, did you read the post above it?

 

I apologise that I didn't predict the existence of the allPlayers command back in 2014.

Share this post


Link to post
Share on other sites
3 hours ago, silentspike said:

 

Well, did you read the post above it?

 

I apologise that I didn't predict the existence of the allPlayers command back in 2014.

No problem, no personal offense on my mind. But it's always better to let some working scripts and explain what can be wrong on former codes in a public forum. (allPlayers or playablesUnits, your code didn't answer to the question, anyway). But perhaps, i anticipated your intention.

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  

×