Jump to content

.NET - getting vehicle next to player?


Recommended Posts



I urgently need an advise how to get the hand on a vehicle Niko stands by. Long story short example:

How would I open a door of the car Niko stands next to?


Thanks in advance!

Link to comment
Share on other sites

private vehicle veh;




veh = World.GetClosestVehicle(Player.Character.Position, 3f); // Parameter1 is the position, Parameter2 is the maximum distance to find a Vehicle.


if (veh != null) //Ensures that the game found a vehicle


GTA.Native.Function.Call("OPEN_CAR_DOOR", veh, 0); // Parameter1 is the Vehicle Handle, Parameter2 is the Door ID




Door ID Parameters can be found here

GTAModding.com - DOOR ID'S

Link to comment
Share on other sites

Wow thanks a lot, how could I miss that under World.? O_o

This snippet is exactly what I need, have some cookies smile.gifcookie.gifcookie.gif

Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
  • 1 User Currently Viewing
    0 members, 0 Anonymous, 1 Guest

  • Create New...

Important Information

By using GTAForums.com, you agree to our Terms of Use and Privacy Policy.