Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- /// <summary>
- /// Spawns a vehicle with a given name, a certain offset from the player.
- /// </summary>
- /// <param name="vehName">Name of the vehicle to spawn.</param>
- /// <param name="offsetPos">The offset position from the player. (Positive X is right, positive Y is front, positive Z is top)</param>
- /// <param name="headingOffset">The heading offset in degrees.</param>
- /// <returns>0 on success, 1 on failed spawn.</returns>
- private int spawnVehExample(string vehName, Vector3 offsetPos, float headingOffset)
- {
- // Get the player heading.
- float vehHeading = Player.Character.Heading;
- // Offset the heading.
- vehHeading += headingOffset;
- // Get the spawn position.
- Vector3 vehPos = Player.Character.GetOffsetPosition(offsetPos);
- // Spawn the vehicle.
- GTA.Vehicle veh = World.CreateVehicle(vehName, vehPos);
- // Check if vehicle is spawned correctly.
- if (veh == null || !veh.Exists())
- {
- // Error code 1: failed to spawn vehicle!
- return 1;
- }
- // Set heading.
- veh.Heading = vehHeading;
- // Success
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement