Skip to main content

VehicleSetPosXYZ

Description

Sets the position of a vehicle in the world. In addition to the X, Y, and Z position, this function allows manipulation of the vehicle’s internal matrix via three extra parameters (a, b, and c), which can distort or rotate the vehicle. The final boolean argument toggles which set of values (position vs. matrix) is applied. (?)

function VehicleSetPosXYZ(car, x, y, z, a, b, c, set) --[[ ... ]] end

Parameters

  • car: handle - A handle to the vehicle.
  • x: number - The new X coordinate for the vehicle.
  • y: number - The new Y coordinate for the vehicle.
  • z: number - The new Z coordinate for the vehicle.
  • a: number - A matrix component that affects orientation/distortion. (optional)
  • b: number - A matrix component that affects orientation/distortion. (optional)
  • c: number - A matrix component that affects orientation/distortion. (optional)
  • set: boolean - Applies matrix values only, ignores position values when false. (optional)

Return Values

None.

Example

function main()
-- Get player's current position
local x, y, z = PedGetPosXYZ(gPlayer)

-- Create a vehicle next to the player
local car = VehicleCreateXYZ(295, x, y + 3, z) -- 295 = Police Car

print("Vehicle created!")

-- Basic positioning (normal use)
VehicleSetPosXYZ(car, x, y + 10, z, 0, 0, 0, true)
Wait(2000)

-- Matrix manipulation example - these create visual distortions
VehicleSetPosXYZ(car, x, y + 10, z, 1, 1, 333, false)
Wait(5000)

-- Reset to normal
VehicleSetPosXYZ(car, x, y + 10, z, 0, 0, 0, true)
end

See Also