SetVehicleRotation: Difference between revisions
From Onset Developer Wiki
Created page with "{{Info|Function|Server|1.0}} {{FuncDescription|__EDIT_ME__}} {{FuncSyntax|SetVehicleRotation(vehicle, x, y, z)}} {{FuncParameters}} {{FuncParam|vehicle|__EDIT_ME__}} {{Func..." |
No edit summary |
||
(4 intermediate revisions by 2 users not shown) | |||
Line 1: | Line 1: | ||
{{Info|Function|Server|1.0}} | {{Info|Function|Server|1.0}} | ||
{{FuncDescription| | {{FuncDescription|Sets the vehicle rotation.}} | ||
{{FuncSyntax|SetVehicleRotation(vehicle, x, y, z)}} | {{FuncSyntax|SetVehicleRotation(vehicle, x, y, z)}} | ||
{{FuncParameters}} | {{FuncParameters}} | ||
{{FuncParam|vehicle| | {{FuncParam|vehicle|The vehicle identifier}} | ||
{{FuncParam|x| | {{FuncParam|x|The pitch rotation}} | ||
{{FuncParam|y| | {{FuncParam|y|The yaw rotation}} | ||
{{FuncParam|z| | {{FuncParam|z|The roll rotation}} | ||
{{FuncReturnValue| | {{FuncReturnValue|Returns '''true''' on success.}} | ||
== Example == | == Example == | ||
<syntaxhighlight lang="Lua"> | |||
function VehicleVelocityReset(player) | |||
local vehicle = GetPlayerVehicle(player) | |||
if (vehicle ~= 0) then | |||
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) | |||
end | |||
end | |||
AddRemoteEvent("VehicleVelocityReset", VehicleVelocityReset) | |||
</syntaxhighlight> | |||
{{RelatedFunctions}} | {{RelatedFunctions}} | ||
{{Template:VehicleFunctions}} |
Latest revision as of 20:28, 30 August 2020
Description
Sets the vehicle rotation.
Syntax
SetVehicleRotation(vehicle, x, y, z)
Parameters
- vehicle
The vehicle identifier - x
The pitch rotation - y
The yaw rotation - z
The roll rotation
Return Value
- Returns true on success.
Example
function VehicleVelocityReset(player)
local vehicle = GetPlayerVehicle(player)
if (vehicle ~= 0) then
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)
end
end
AddRemoteEvent("VehicleVelocityReset", VehicleVelocityReset)
See also
- CreateVehicle
- DestroyVehicle
- IsValidVehicle
- GetVehicleCount
- GetAllVehicles
- GetVehicleModel
- GetVehicleModelName
- SetVehicleRespawnParams
- IsVehicleStreamedIn
- GetStreamedVehiclesForPlayer
- GetStreamedVehicles
- SetVehicleLocation
- GetVehicleLocation
- SetVehicleRotation
- GetVehicleRotation
- SetVehicleHeading
- GetVehicleHeading
- SetVehicleHealth
- GetVehicleHealth
- SetVehicleLicensePlate
- GetVehicleVelocity
- GetVehicleDriver
- GetVehiclePassenger
- GetVehicleNumberOfSeats
- SetVehicleColor
- GetVehicleColor
- SetVehicleLinearVelocity
- SetVehicleAngularVelocity
- GetVehicleGear
- SetVehicleHoodRatio
- GetVehicleHoodRatio
- SetVehicleTrunkRatio
- GetVehicleTrunkRatio
- StartVehicleEngine
- StopVehicleEngine
- GetVehicleEngineState
- SetVehicleLightEnabled
- GetVehicleLightState
- SetVehicleDamage
- GetVehicleDamage
- AttachVehicleNitro