Quantcast

Jump to content

» «
Photo

how do i spawn vehicles at specific locations

8 replies to this topic
avatar0068
  • avatar0068

    Player Hater

  • Members
  • Joined: 18 Feb 2013

#1

Posted 19 March 2013 - 12:43 PM

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.

NomeSkavinski
  • NomeSkavinski

    Player Hater

  • Members
  • Joined: 18 Feb 2013

#2

Posted 19 March 2013 - 03:58 PM

If your using a script hook:
CODE

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


then you could do:
CODE

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


if your not have a look through that:
http://www.gtamoddin...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.

avatar0068
  • avatar0068

    Player Hater

  • Members
  • Joined: 18 Feb 2013

#3

Posted 19 March 2013 - 04:05 PM

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^^

NomeSkavinski
  • NomeSkavinski

    Player Hater

  • Members
  • Joined: 18 Feb 2013

#4

Posted 19 March 2013 - 04:19 PM

Ok, i see thats fair enough.

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

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...#d-2012-express

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

avatar0068
  • avatar0068

    Player Hater

  • Members
  • Joined: 18 Feb 2013

#5

Posted 19 March 2013 - 05:18 PM

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

NomeSkavinski
  • NomeSkavinski

    Player Hater

  • Members
  • Joined: 18 Feb 2013

#6

Posted 19 March 2013 - 05:22 PM

Change:
CODE

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


To:
CODE

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

avatar0068
  • avatar0068

    Player Hater

  • Members
  • Joined: 18 Feb 2013

#7

Posted 19 March 2013 - 07:45 PM

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,

NomeSkavinski
  • NomeSkavinski

    Player Hater

  • Members
  • Joined: 18 Feb 2013

#8

Posted 19 March 2013 - 07:53 PM

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

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.

avatar0068
  • avatar0068

    Player Hater

  • Members
  • Joined: 18 Feb 2013

#9

Posted 26 March 2013 - 03:33 PM

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




1 user(s) are reading this topic

0 members, 1 guests, 0 anonymous users