SetVehicleLocation
From Onset Developer Wiki
Description
Teleports a vehicle to a specified location.
Syntax
SetVehicleLocation(vehicle, x, y, z)
Parameters
- vehicle
The vehicle identifier. - x
World X location. - y
World Y location. - z
World Z location.
Return Value
- Returns true on success. false if the vehicle does not exist.
Example
function TeleportTo(player, x, y, z, h)
h = h or -1.0
if (GetPlayerVehicleSeat(player) == 1) then
local vehicle = GetPlayerVehicle(player)
SetVehicleLocation(vehicle, x, y, z)
if (h ~= -1.0) then
SetVehicleHeading(vehicle, h)
end
-- Reset velocity
SetVehicleLinearVelocity(vehicle, 0.0, 0.0, 0.0, true)
SetVehicleAngularVelocity(vehicle, 0.0, 0.0, 0.0, true)
local rx, ry, rz = GetVehicleRotation(vehicle)
-- Reset pitch and roll, leave yaw alone
SetVehicleRotation(vehicle, 0.0, ry, 0.0)
else
SetPlayerLocation(player, x, y, z)
if (h ~= -1.0) then
SetPlayerHeading(player, h)
end
end
ResetPlayerCamera(player)
end
See also
__EDIT_ME__