IsVehicleOnGround: Difference between revisions

From Multi Theft Auto: Wiki
Jump to navigation Jump to search
No edit summary
(Added note regarding isVehicleWheelOnGround)
 
(11 intermediate revisions by 10 users not shown)
Line 1: Line 1:
__NOTOC__  
{{Server client function}}
<!-- Describe in plain english what this function does. Don't go into details, just give an overview -->
__NOTOC__
This fake function is for use with blah & blah and does blahblahblabhalbhl
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==  
<!-- NOTE: don't use 'special' names for variable names, e.g. you shouldn't be writing things like 'player player, vehicle vehicle', instead write something like 'player thePlayer, vehicle vehicleToGetInto'. This is less confusing and prevents the syntax highlighting being odd -->
<syntaxhighlight lang="lua">
<syntaxhighlight lang="lua">
bool isVehicleOnGround ( vehicle )
bool isVehicleOnGround ( vehicle theVehicle )
</syntaxhighlight>  
</syntaxhighlight>  
 
{{OOP||[[vehicle]]:isOnGround|onGround}}
===Required Arguments===  
===Required Arguments===  
<!-- List each argument one per line. This should be the argument's name as in the argument list above, NOT the argument's data type -->
*'''theVehicle:''' The vehicle you wish to check.
*'''argumentName:''' description
 
<!-- Only include this section below if there are optional arguments -->
===Optional Arguments===
{{OptionalArg}}
*'''argumentName2:''' description
*'''argumentName3:''' description


===Returns===
===Returns===
<!-- Make this descriptive. Explain what cases will return false. If you're unsure, add a tag to it so we can check -->
Returns ''true'' if vehicle is on the ground, ''false'' if it is not.
Returns ''true'' if blah, ''false'' otherwise.


==Example==  
==Example==  
<!-- Explain what the example is in a single sentance -->
 
This example does...
This example tells you when you've jumped out of a vehicle.
<!-- Add the code below, an emphasis should be on making it clear, not optimized. You could provide two versions if you wish, one clear and well commented, the other optimized -->
 
<section name="Server" class="server" show="true">
<syntaxhighlight lang="lua">
<syntaxhighlight lang="lua">
--This line does...
function checkVState ( vehicle, seat, jacked )
blabhalbalhb --abababa
vehName = getVehicleName ( vehicle )
--This line does this...
 
mooo
if isVehicleOnGround ( vehicle ) == false then
outputChatBox ( "You jumped out of a "..vehName.."!", source, 255, 0, 0  )
end
 
end
addEventHandler ( "onPlayerVehicleExit", getRootElement(), checkVState )
</syntaxhighlight>
</syntaxhighlight>
</section>
== Issues ==
{{Issues|
{{Issue|471|isVehicleOnGround sometimes returns false incorrectly}}
{{Issue|2093|isVehicleOnGround does not work after setVehicleHandling}}
}}


==See Also==
==See Also==
<!-- Change FunctionArea to the area that this function is in on the main function list page, e.g. Server, Player, Vehicle etc -->
{{Vehicle functions}}
{{FunctionArea_functions}}
[[Category:Incomplete]] -- leave this unless you complete the function

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