IsVehicleWheelOnGround: Difference between revisions

From Multi Theft Auto: Wiki
Jump to navigation Jump to search
Line 35: Line 35:
     end
     end
end
end
</syntaxhighlight>
</section>


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

Revision as of 14:10, 18 February 2018

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 isVehicleWheelCollided ( vehicle theVehicle, string|number wheel )

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

Click to collapse [-]
Client

This example allows a player to lock his vehicle when he is inside it.

Green = tocolor(0,255,0,255)
Red = tocolor(255,0,0,255)
addEventHandler("onClientRender",root,function()
    local veh = getPlayerOccupiedVehicle ( localPlayer )
    if isElement(veh)then
        dxDrawRectangle(100,100,20,20,isVehicleWheelCollided(veh,0) and Green or Red)
        dxDrawRectangle(100,140,20,20,isVehicleWheelCollided(veh,1) and Green or Red)
        dxDrawRectangle(140,100,20,20,isVehicleWheelCollided(veh,2) and Green or Red)
        dxDrawRectangle(140,140,20,20,isVehicleWheelCollided(veh,3) and Green or Red)
    end
end

See Also