Jump to content
gc8

Detecting vehicle proplem

Recommended Posts

Hi

I have always used the vehicle command to detect if player is inside a vehicle but today I noticed something odd going on.

 

If I put player in a tank as driver the player variable is different from (vehicle player) like it should be. But if you put player as commander in tank then: player == (vehicle player) !

 

does anybody know why is this? maybe this is a bug in the vehicle command?

 

And what are valid ways to detect if unit is in any vehicle?

 

thx!

Share this post


Link to post
Share on other sites

Nevermind.

I found out that even the unit names are same the "(vehicle player) != player" still works.

 

Share this post


Link to post
Share on other sites

I use a newer, faster command for checking if a player is in a vehicle. This is how some people do it: !isNull objectParent player

  • Like 1

Share this post


Link to post
Share on other sites
22 hours ago, gc8 said:

Nevermind.

I found out that even the unit names are same the "(vehicle player) != player" still works.

 

Wait, what? You just said player == vehicle player true, and now vehicle player != player also true? Did I miss something?

Share this post


Link to post
Share on other sites
18 minutes ago, killzone_kid said:

Wait, what? You just said player == vehicle player true, and now vehicle player != player also true? Did I miss something?

 

what I mean was that (str player) == (str (vehicle player)) because I put both lines vehicle & vehicle player in the debug console and they have same value. But vehicle player != player is still true also. because it compares the objects that happen to have same name.

 

here's a screenshot of what I mean (player being inside a turret): sameval.png

Share this post


Link to post
Share on other sites

vehicle player returns the vehicle the player is in.  vehicle player != player is always true if the player is in a vehicle.  It is false if the player is not in a vehicle.  I just tested:

if(vehicle player != player) then {hint "player in vehicle";}else{hint "player not in vehicle";};

In a car, truck, tank, helicopter, and enemy tank in the VR.  When I was in a vehicle, the "player in vehicle" fired off.  When I was a foot mobile, the "player not in vehicle" fired off.  It may be possible that your tank is a mod and is not properly setup in its class configs.

Share this post


Link to post
Share on other sites
4 hours ago, stuguy said:

It may be possible that your tank is a mod and is not properly setup in its class configs.

 

the confusion was just that the tank has same name as the commander. as shown in the screenshot I posted.

but yeah (vehicle player != player) works

Share this post


Link to post
Share on other sites
1 minute ago, gc8 said:

the confusion was just that the tank has same name as the commander

That's why I always use unique variables or I select units or vehicles through logic.

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

×