IsVehicleWheelOnGround: Difference between revisions

From Multi Theft Auto: Wiki
Jump to navigation Jump to search
(Created page with "__NOTOC__ {{Client function}} {{New feature/item|3.0160|1.6.0|11854| This function returns a boolean whether the vehicle's wheel is on ground (true) or in air (false). }}...")
 
m (Type unions are '/', not '|'. See triggerLatentClientEvent, hasObjectPermissionTo, banPlayer, etc.)
 
(12 intermediate revisions by 6 users not shown)
Line 1: Line 1:
__NOTOC__  
__NOTOC__  
{{Client function}}
{{Client function}}
{{New feature/item|3.0160|1.6.0|11854|
{{New feature/item|3.0156|1.5.5|11854|
This function returns a boolean whether the [[vehicle]]'s wheel is on ground (true) or in air (false).
This function returns a [[boolean]] whether the [[vehicle]]'s wheel is on ground (true) or in air (false).
}}
}}
{{Note|In vehicles with 3 wheels, the wheels are combined 2 in 1, in motorbikes only the left - <code>"front_left"</code> and <code>"rear_left"</code>}}
{{Note|In vehicles with 3 wheels, the wheels are combined 2 in 1, in motorbikes only the left - <code>"front_left"</code> and <code>"rear_left"</code>}}


==Syntax==  
==Syntax==  
<syntaxhighlight lang="lua">bool isVehicleWheelCollided ( vehicle theVehicle, string|number wheel )</syntaxhighlight>  
<syntaxhighlight lang="lua">bool isVehicleWheelOnGround ( vehicle theVehicle, string/int wheel )</syntaxhighlight>  
 
{{OOP||[[vehicle]]:isWheelOnGround}}
===Required Arguments===  
===Required Arguments===  
*'''theVehicle''' The [[vehicle]], which you want to check.
*'''theVehicle''' The [[vehicle]], which you want to check.
Line 21: Line 21:


==Example==
==Example==
{{Needs Example}}
This example displays four colored rectangles on the screen. If the wheel is colliding, the rectangle will be green, otherwise it will be red.
<syntaxhighlight lang="lua">
local Green = tocolor(0, 255, 0, 255)
local Red = tocolor(255, 0, 0, 255)
 
addEventHandler( "onClientRender", root,
    function( )
        local theVehicle = getPedOccupiedVehicle( localPlayer )
 
        if isElement( theVehicle ) then
            dxDrawRectangle( 100, 100, 20, 20, isVehicleWheelOnGround ( theVehicle, 0 ) and Green or Red )
            dxDrawRectangle( 100, 140, 20, 20, isVehicleWheelOnGround ( theVehicle, 1 ) and Green or Red )
            dxDrawRectangle( 140, 100, 20, 20, isVehicleWheelOnGround ( theVehicle, 2 ) and Green or Red )
            dxDrawRectangle( 140, 140, 20, 20, isVehicleWheelOnGround ( theVehicle, 3 ) and Green or Red )
        end
    end
)
</syntaxhighlight>


==See Also==
==See Also==
{{Client_vehicle_functions}}
{{Client_vehicle_functions}}

Latest revision as of 11:37, 30 April 2021

This function returns a boolean whether the vehicle's wheel is on ground (true) or in air (false).

[[{{{image}}}|link=|]] Note: In vehicles with 3 wheels, the wheels are combined 2 in 1, in motorbikes only the left - "front_left" and "rear_left"

Syntax

bool isVehicleWheelOnGround ( vehicle theVehicle, string/int wheel )

OOP Syntax Help! I don't understand this!

Method: vehicle:isWheelOnGround(...)


Required Arguments

  • theVehicle The vehicle, which you want to check.
  • wheel The wheel name or number, see list below:
    • "front_left" or 0
    • "rear_left" or 1
    • "front_right" or 2
    • "rear_right" or 3

Returns

Returns true if the vehicle wheel is on ground/collided, false otherwise.

Example

This example displays four colored rectangles on the screen. If the wheel is colliding, the rectangle will be green, otherwise it will be red.

local Green = tocolor(0, 255, 0, 255)
local Red = tocolor(255, 0, 0, 255)

addEventHandler( "onClientRender", root,
    function( )
        local theVehicle = getPedOccupiedVehicle( localPlayer )

        if isElement( theVehicle ) then
            dxDrawRectangle( 100, 100, 20, 20, isVehicleWheelOnGround ( theVehicle, 0 ) and Green or Red )
            dxDrawRectangle( 100, 140, 20, 20, isVehicleWheelOnGround ( theVehicle, 1 ) and Green or Red )
            dxDrawRectangle( 140, 100, 20, 20, isVehicleWheelOnGround ( theVehicle, 2 ) and Green or Red )
            dxDrawRectangle( 140, 140, 20, 20, isVehicleWheelOnGround ( theVehicle, 3 ) and Green or Red )
        end
    end
)

See Also