SetVehicleWheelsRotation: Difference between revisions

From Multi Theft Auto: Wiki
Jump to navigation Jump to search
(Created page with "re")
 
No edit summary
Line 1: Line 1:
re
__NOTOC__
{{Client function}}
Allows the scripter to manipulate wheel rotation for vehicles. This function supports Automobiles, Bikes (Including BMX), and Trailers.
 
==Syntax==
<syntaxhighlight lang="lua">
bool setVehicleWheelsRotation ( vehicle vehicleElement, float rotation )
</syntaxhighlight>
{{OOP||[[vehicle]]:setVehicleWheelsRotation|vehicleWheelsRotation|getVehicleWheelsRotation}}
 
===Required Arguments===
* '''vehicleElement:''' the vehicle (Automobile, Bike, or Trailer) 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 the player is in, and also for any attached trailer.
 
<section name="Client" class="client" show="true">
<syntaxhighlight lang="lua">
addEventHandler("onClientVehicleEnter", getRootElement(),
    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}}

Revision as of 05:21, 30 June 2024

Allows the scripter to manipulate wheel rotation for vehicles. This function supports Automobiles, Bikes (Including BMX), and Trailers.

Syntax

bool setVehicleWheelsRotation ( vehicle vehicleElement, float rotation )

OOP Syntax Help! I don't understand this!

Method: vehicle:setVehicleWheelsRotation(...)
Variable: .vehicleWheelsRotation
Counterpart: getVehicleWheelsRotation


Required Arguments

  • vehicleElement: the vehicle (Automobile, Bike, or Trailer) 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 the player is in, and also for any attached trailer.

Click to collapse [-]
Client
addEventHandler("onClientVehicleEnter", getRootElement(),
    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

Shared