Jump to content
    1. Welcome to GTAForums!

    1. GTANet.com

    1. GTA Online

      1. Los Santos Drug Wars
      2. Updates
      3. Find Lobbies & Players
      4. Guides & Strategies
      5. Vehicles
      6. Content Creator
      7. Help & Support
    2. Red Dead Online

      1. Blood Money
      2. Frontier Pursuits
      3. Find Lobbies & Outlaws
      4. Help & Support
    3. Crews

    1. Grand Theft Auto Series

      1. Bugs*
      2. St. Andrews Cathedral
    2. GTA VI

    3. GTA V

      1. Guides & Strategies
      2. Help & Support
    4. GTA IV

      1. The Lost and Damned
      2. The Ballad of Gay Tony
      3. Guides & Strategies
      4. Help & Support
    5. GTA San Andreas

      1. Classic GTA SA
      2. Guides & Strategies
      3. Help & Support
    6. GTA Vice City

      1. Classic GTA VC
      2. Guides & Strategies
      3. Help & Support
    7. GTA III

      1. Classic GTA III
      2. Guides & Strategies
      3. Help & Support
    8. Portable Games

      1. GTA Chinatown Wars
      2. GTA Vice City Stories
      3. GTA Liberty City Stories
    9. Top-Down Games

      1. GTA Advance
      2. GTA 2
      3. GTA
    1. Red Dead Redemption 2

      1. PC
      2. Help & Support
    2. Red Dead Redemption

    1. GTA Mods

      1. GTA V
      2. GTA IV
      3. GTA III, VC & SA
      4. Tutorials
    2. Red Dead Mods

      1. Documentation
    3. Mod Showroom

      1. Scripts & Plugins
      2. Maps
      3. Total Conversions
      4. Vehicles
      5. Textures
      6. Characters
      7. Tools
      8. Other
      9. Workshop
    4. Featured Mods

      1. Design Your Own Mission
      2. OpenIV
      3. GTA: Underground
      4. GTA: Liberty City
      5. GTA: State of Liberty
    1. Rockstar Games

    2. Rockstar Collectors

    1. Off-Topic

      1. General Chat
      2. Gaming
      3. Technology
      4. Movies & TV
      5. Music
      6. Sports
      7. Vehicles
    2. Expression

      1. Graphics / Visual Arts
      2. GFX Requests & Tutorials
      3. Writers' Discussion
      4. Debates & Discussion
    1. Announcements

    2. Support

    3. Suggestions

Happy Holidays from the GTANet team!

how do i spawn vehicles at specific locations


avatar0068
 Share

Recommended Posts

how do i spawn vehicles at specific locations using a script made with visual basic.

say i wanted to spawn a bus at the co-ordinates below how would i write the command.

X= 1002.408569, Y= 270.020752, Z= 31.459654

 

any help would be appreciated.

Link to comment
Share on other sites

NomeSkavinski

If your using a script hook:

 

Vehicle v = World.CreateVehicle("NAME_OF_VEHICLE", new GTA.Vector3(1002.408569F, 270.020752F, 31.459654F));

 

 

then you could do:

 

Player.Character.WarpIntoVehicle(v, VehicleSeat.Driver);

 

 

if your not have a look through that:

http://www.gtamodding.com/index.php?title=...ative_functions

 

But i'd seriously recommend using a script hook.

 

Why not use a simple trainer to spawn the car for you?

 

Hope it helped.

Link to comment
Share on other sites

thanks for the reply,

yes i am using scripthook for this and the reason i dont use native trainer is that its for a script i am working on as a progect, all the missionscripts i use call there own spawns and id like to do it as well smile.gif

 

thanks for the help, ill try that line you posted^^

Link to comment
Share on other sites

NomeSkavinski

Ok, i see thats fair enough.

 

One thing i should mention is when you spawn the car you should use:

 

v.NoLongerNeeded();

 

 

That way when your travelling around the level you wont find the car again, it just keeps things cleaner. But it entirely depends on how you wish to manage your objects or your intentions of the script.

 

Are you using an IDE (Intergrated Development Environment), if not that will be so much helpful to you for finding what you can use or need for making vehicles or pedestrains etc.

 

http://www.microsoft.com/visualstudio/eng/...#d-2012-express

 

Make sure you get the express edition, thats the free one. There are others, feel free to use another.

Link to comment
Share on other sites

thanks again, i can spawn the vehicle i want and where i want it to be, but it spawns about 4 feet in the air and are facing the wrong way...haha

i guess i need an orientation command in there as well devil.gif

Link to comment
Share on other sites

NomeSkavinski

Change:

 

Vehicle v = World.CreateVehicle("NAME_OF_VEHICLE", new GTA.Vector3(1002.408569F, 270.020752F, 31.459654F));

 

 

To:

 

Vehicle v = World.CreateVehicle("NAME_OF_VEHICLE", new GTA.Vector3(1002.408569F, 270.020752F, 0).ToGround());v.PlaceOnGroundProperly();v.PlaceOnNextStreetProperly();

 

 

Hope this sends you in the right direction

Link to comment
Share on other sites

the vehicle is sitting on the ground nice now, but still faces the wrong direction, i did try the vehicle.heading command but every time i add this no spawn!

ill keep trying,

Link to comment
Share on other sites

NomeSkavinski

I solved a similar problem in my RampSpawner script, put this after you have spawned the car:

 

v.Rotation = new GTA.Vector3(0, 0, (Game.CurrentCamera.Heading - 180)

 

 

This should face the car at the camera. So you could change Game.CurrentCamera.Heading with Player.Character.Heading if you always wanted it to face the player when spawning regardless of where the camera is facing. the 180 at the end rotates it 180 degrees, so if its still wrong either remove it or try different values.

Link to comment
Share on other sites

i figured it out,

 

declerations

Dim pos As New Vector3

Dim vehicle As vehicle

 

pos = New Vector3(1002.49F, 269.95F, 31.46F) this is where your vehicle will be placed

vehicle = World.CreateVehicle("your vehicle", pos) your selected vehicle

vehicle.Heading = 144.9825F the rotation of your selected vehicle

 

in vb just change the numbers to get the desired rotation of the vehicle, hope this helps someone. smile.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
 Share

  • 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.