SetVehicleWheelsRotation: Difference between revisions

From Multi Theft Auto: Wiki
Jump to navigation Jump to search
(Created page with "re")
 
(Remove obsolete Requirements section)
Tag: Manual revert
 
(7 intermediate revisions by 2 users not shown)
Line 1: Line 1:
re
__NOTOC__
{{Client function}}
This function is used to manipulate the wheel rotation of a vehicle. Cars, Bikes (including BMX) and Trailers are supported.
 
==Syntax==
<syntaxhighlight lang="lua">
bool setVehicleWheelsRotation ( vehicle theVehicle, float rotation )
</syntaxhighlight>
 
===Required Arguments===
* '''theVehicle:''' the vehicle whose wheel rotation is to be set.
* '''rotation:''' the new wheel rotation value.
 
===Returns===
Returns ''true'' if successful, ''false'' otherwise.
 
==Example==
This example sets the wheel rotation of the vehicle when the player gets into any vehicle and if there is any attached trailer.
 
<section name="Client" class="client" show="true">
<syntaxhighlight lang="lua">
addEventHandler("onClientVehicleEnter", root,
    function()
        local theVeh = getPedOccupiedVehicle(localPlayer)
        if setVehicleWheelsRotation(theVeh, 0) then
            outputChatBox("SET OK")
        else
            outputChatBox("SET FAILED")
        end
    end
)
 
addEventHandler("onClientPreRender", root, function()
    local theVeh = getPedOccupiedVehicle(localPlayer)
    if theVeh then
        setVehicleWheelsRotation(theVeh, 0)
        -- also do it for trailer
        local trailer = getVehicleTowedByVehicle(theVeh)
        if trailer then
            setVehicleWheelsRotation(trailer, 0)
        end
    end
end)
</syntaxhighlight>
</section>
 
==See Also==
{{Client vehicle functions}}

Latest revision as of 17:34, 7 November 2024

This function is used to manipulate the wheel rotation of a vehicle. Cars, Bikes (including BMX) and Trailers are supported.

Syntax

bool setVehicleWheelsRotation ( vehicle theVehicle, float rotation )

Required Arguments

  • theVehicle: the vehicle whose wheel rotation is to be set.
  • rotation: the new wheel rotation value.

Returns

Returns true if successful, false otherwise.

Example

This example sets the wheel rotation of the vehicle when the player gets into any vehicle and if there is any attached trailer.

Click to collapse [-]
Client
addEventHandler("onClientVehicleEnter", root,
    function()
        local theVeh = getPedOccupiedVehicle(localPlayer)
        if setVehicleWheelsRotation(theVeh, 0) then 
            outputChatBox("SET OK")
        else
            outputChatBox("SET FAILED")
        end
    end
)

addEventHandler("onClientPreRender", root, function()
    local theVeh = getPedOccupiedVehicle(localPlayer)
    if theVeh then
        setVehicleWheelsRotation(theVeh, 0)
        -- also do it for trailer
        local trailer = getVehicleTowedByVehicle(theVeh)
        if trailer then
            setVehicleWheelsRotation(trailer, 0)
        end
    end
end)

See Also