Airplane spawning problem.
-
Hello to All moders! I have a script that will spawn a plane:
v = World.CreateVehicle("Titan", Game.Player.Character.Position.Around(1500.0F))
checkdist()
If isclose = False Then
pedselect()
s1 = v.CreatePedOnSeat(VehicleSeat.Driver, "s_m_y_Marine_03")
weapselect()
s1.Weapons.Give(weaphash, 999, True, True)
s1.MarkAsNoLongerNeeded()I need the plane
to spawn above the player's position, some number of feet up. (That is, you need to replace: Game.Player.Character.Position.Around (1500.0F)). Well, if in simple words I need to change the coordinate of the height Z, and leave X and Y at random. I can't find a solution in any way. Thanks in advance to everyone who will help!
Regards ArkadiPro1.
-
@ArkadiPro1 You do realize your plane is going to fall out of the sky right?
You'll need to add a random function for x and y and then do something like this:Vector3 Coord = Function.Call<Vector3>(Hash.GET_ENTITY_COORDS, Game.Player.Character, false);
Vehicle v = World.CreateVehicle("Titan", Game.Player.Character.GetOffsetInWorldCoords(new Vector3(0, 0, Coord.Z + 1500F)));
replace 0, 0, with your random floats for x and y.
-
float positionz = Game.Player.Character.Position.Z;
positionz += 5; // 5 feet above playerModel planemodel = new Model("titan"); planemodel.Request(10000); if (planemodel.IsValid && planemodel.IsInCdImage) { while (!planemodel.IsLoaded) Script.Wait(50); planevec = World.CreateVehicle(planemodel, new Vector3(Game.Player.Character.Position.X, Game.Player.Character.Position.Y, positionz)); }
make sure to put planevec in your main
-
@M8T I think he wants random values for X and Y.
-
This code keeps the X and Y values from the Around function, and sets Z to 5 meters above the player.
pos = Game.Player.Character.Position.Around(1500.0F) pos.Z = Game.Player.Character.Position.Z + 5F ' five meters above player v = World.CreateVehicle("Titan", pos) checkdist() If isclose = False Then pedselect() s1 = v.CreatePedOnSeat(VehicleSeat.Driver, "s_m_y_Marine_03") weapselect() s1.Weapons.Give(weaphash, 999, True, True) s1.MarkAsNoLongerNeeded()
-
Thanks everyone! I'll take a look, and then I'll write what turned out to be a worker.
-
This post is deleted!