Jump to content
Sign in to follow this  
npmproductions13

How to target current vehicle that player is in

Recommended Posts

Hi all i was wondering if someone would be kind enough to show me or point me in the right direction. I need to target the car the player is in. For example if somone is in a SUV and approachs a box and activates a script i need that script to target the vehicle that the player who activated it is in. I need this to work without the vehicle getting a name. 

 

Sorry about the bad description above its just its hard to explain  :unsure:

 

Thanks Irish

Share this post


Link to post
Share on other sites

i ve only understood a half of that therefore my answer is short. maybe im to tired

_vec = vehicle player;

Edited by sarogahtyp
  • Like 1

Share this post


Link to post
Share on other sites

i ve only underst0od a half of that therefore my answer is short. maybe im to tired

_vec = vehicle player;

Ill try this thanks. I found it hard to explain what i was looking for sorry for the shit English

Share this post


Link to post
Share on other sites
_vehicle = (vehicle player);

is indeed the right way to 'adress' the vehicle of the player. If you want, for example, use it in a trigger's condition you could put this in the trigger's condition field:

(vehicle player) in thisList

That's generally a good way since player is always some kind of vehicle. If the player is running around as an infantry unit he is

(vehicle player) == player

Therefore you can find out if the player is sitting in a vehicle by checking for

(vehicle player) != player

So let's say you want to check if the player is inside a trigger and is actually sitting in a car, you'd have to put this in the trigger's condition field:

(vehicle player) in thisList && (vehicle player) != player

And to be absolutely thorough, you can even check if the vehicle is an actual ground vehicle by checking the height of the player's vehicle:

(vehicle player) in thisList && (vehicle player) != player && ((getPos (vehicle player)) select 2 < 5

That should provide you with lots of ways to check for and adress the player's vehicle.

  • Like 1

Share this post


Link to post
Share on other sites

Some questions:

 

Is it a multiplayer problem?

You said a script should target those player. Do u only need the script to know who the player is or is that script controlling AI which should taget at the player?

If it is a multiplayer problem then I need some info where the script is running, at client or at server and how is that script started? Is it started by trigger, eventhandler or is it always running and tracking the player if it reaches those box?

 

If u answer some of those questions then u could get some more help. Posting ur script will us help to help u, too.

 

EDIT: I wrote that before I read the previous post...

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  

×