IsPedOnGround: Difference between revisions

From Multi Theft Auto: Wiki
Jump to navigation Jump to search
(New page: __NOTOC__ {{Client function}} This function is used to determine whether or not a ped is on the ground. This is for on-foot usage only. ==Syntax== <syntaxhighlight lang="lua"> bool isPedOnGround ( ped the...)
 
(Updated issues)
 
(8 intermediate revisions by 4 users not shown)
Line 1: Line 1:
__NOTOC__
__NOTOC__
{{Client function}}
{{Server client function}}
This function is used to determine whether or not a ped is on the ground. This is for on-foot usage only.
This function is used to determine whether or not a ped is on the ground. This is for on-foot usage only.


Line 7: Line 7:
bool isPedOnGround ( ped thePed )
bool isPedOnGround ( ped thePed )
</syntaxhighlight>
</syntaxhighlight>
{{OOP||[[ped]]:isOnGround|onGround}}


===Required Arguments===
===Required Arguments===
Line 12: Line 13:


===Returns===
===Returns===
Returns ''true'' if the ped is on foot and on the ground, ''false'' otherwise, even if he is in a car that stands still.
Returns ''true'' if the ped is on foot and on the ground, ''false'' otherwise, even if he is in a car that stands still or on object outside world map.


==Example==
==Example==
<section name="Server" class="server" show="true">
This example checks if the player who enters the 'amiflying' command is on the ground and outputs a message.
This example checks if the player who enters the 'amiflying' command is on the ground and outputs a message.
<syntaxhighlight lang="lua">
<syntaxhighlight lang="lua">
function isHeFlying ( sourcePlayer )
function isHeFlying ( sourcePlayer )
     if ( isPedOnGround ( sourcePlayer ) ) then
     if isPedOnGround ( sourcePlayer ) then
         outputChatBox ( "No, you're not flying, you're just stoned!", sourcePlayer )
         outputChatBox ( "No, you're not flying, you're just stoned!", sourcePlayer )
     else
     else
Line 26: Line 28:
addCommandHandler ( "amiflying", isHeFlying )
addCommandHandler ( "amiflying", isHeFlying )
</syntaxhighlight>
</syntaxhighlight>
</section>
== Issues ==
{{Issues|
{{Issue|534|isPedOnGround issues}}
}}


==See Also==
==See Also==
{{Client_ped_functions}}
{{Ped_functions}}

Latest revision as of 10:27, 30 January 2022

This function is used to determine whether or not a ped is on the ground. This is for on-foot usage only.

Syntax

bool isPedOnGround ( ped thePed )

OOP Syntax Help! I don't understand this!

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


Required Arguments

  • thePed: The ped you are checking.

Returns

Returns true if the ped is on foot and on the ground, false otherwise, even if he is in a car that stands still or on object outside world map.

Example

Click to collapse [-]
Server

This example checks if the player who enters the 'amiflying' command is on the ground and outputs a message.

function isHeFlying ( sourcePlayer )
    if isPedOnGround ( sourcePlayer ) then
        outputChatBox ( "No, you're not flying, you're just stoned!", sourcePlayer )
    else
        outputChatBox ( "Is it a bird, is it a plane... No it's " .. getPlayerName ( sourcePlayer ) .. "!", sourcePlayer )
    end
end
addCommandHandler ( "amiflying", isHeFlying )

Issues

Issue ID Description
#534 isPedOnGround issues

See Also