IsVehicleOnGround: Difference between revisions

From Multi Theft Auto: Wiki
Jump to navigation Jump to search
(Added note regarding isVehicleWheelOnGround)
 
(5 intermediate revisions by 5 users not shown)
Line 2: Line 2:
__NOTOC__
__NOTOC__
Checks to see if a vehicle has contact with the ground.
Checks to see if a vehicle has contact with the ground.
{{Note|This function has a few issues, see below. Consider using the clientside function [[isVehicleWheelOnGround]] instead.}}


==Syntax==  
==Syntax==  
Line 7: Line 9:
bool isVehicleOnGround ( vehicle theVehicle )
bool isVehicleOnGround ( vehicle theVehicle )
</syntaxhighlight>  
</syntaxhighlight>  
 
{{OOP||[[vehicle]]:isOnGround|onGround}}
===Required Arguments===  
===Required Arguments===  
*'''theVehicle:''' The vehicle you wish to check.
*'''theVehicle:''' The vehicle you wish to check.
Line 18: Line 20:
This example tells you when you've jumped out of a vehicle.
This example tells you when you've jumped out of a vehicle.


<section name="Server" class="server" show="true">
<syntaxhighlight lang="lua">
<syntaxhighlight lang="lua">
function checkVState ( vehicle, seat, jacked )
function checkVState ( vehicle, seat, jacked )
Line 28: Line 31:
end
end
addEventHandler ( "onPlayerVehicleExit", getRootElement(), checkVState )
addEventHandler ( "onPlayerVehicleExit", getRootElement(), checkVState )
</syntaxhighlight>
</section>


</syntaxhighlight>
== Issues ==
{{Issues|
{{Issue|471|isVehicleOnGround sometimes returns false incorrectly}}
{{Issue|2093|isVehicleOnGround does not work after setVehicleHandling}}
}}


==See Also==
==See Also==
{{Vehicle functions}}
{{Vehicle functions}}
[[Category:Needs_Example]]

Latest revision as of 21:15, 31 January 2022

Checks to see if a vehicle has contact with the ground.

[[{{{image}}}|link=|]] Note: This function has a few issues, see below. Consider using the clientside function isVehicleWheelOnGround instead.

Syntax

bool isVehicleOnGround ( vehicle theVehicle )

OOP Syntax Help! I don't understand this!

Method: vehicle:isOnGround(...)
Variable: .onGround


Required Arguments

  • theVehicle: The vehicle you wish to check.

Returns

Returns true if vehicle is on the ground, false if it is not.

Example

This example tells you when you've jumped out of a vehicle.

Click to collapse [-]
Server
function checkVState ( vehicle, seat, jacked )
	vehName = getVehicleName ( vehicle )

	if isVehicleOnGround ( vehicle ) == false then
		outputChatBox ( "You jumped out of a "..vehName.."!", source, 255, 0, 0  )
	end

end
addEventHandler ( "onPlayerVehicleExit", getRootElement(), checkVState )

Issues

Issue ID Description
#471 isVehicleOnGround sometimes returns false incorrectly
#2093 isVehicleOnGround does not work after setVehicleHandling

See Also