Ped::isInVehicle: Difference between revisions

From RAGE Multiplayer Wiki
(Created page with " {{ClientsideJsFunction}} {{JSContainer| ===Required Params=== *'''ped:''' {{RageType|number}} *'''vehicle:''' {{RageType|number}} *'''atGetIn:''' {{RageType|boolean}} ===Return value=== *''' {{RageType|boolean}} ''' ==Syntax== <syntaxhighlight lang="javascript"> mp.game.ped.isInVehicle(ped, vehicle, atGetIn) </syntaxhighlight> ==Example== <syntaxhighlight lang="javascript"> //todo </syntaxhighlight> }} ==See also== {{Ped_s_function_c}} Category:Clientside API [...")
 
No edit summary
 
Line 1: Line 1:
{{ClientsideJsFunction}}
{{ClientsideJsFunction}}
{{JSContainer|
{{JSContainer|


== Description ==
This function checks if a specified pedestrian (ped) is currently inside a given vehicle. It can also check if the ped is in the process of entering the vehicle, depending on the value of `atGetIn`. This function is helpful for determining when a character is in or near entering a specific vehicle, allowing for additional gameplay logic to be applied.


===Required Params===
=== Required Params ===
*'''ped:''' {{RageType|number}}
*'''ped:''' {{RageType|number}} - The pedestrian handle to check.
*'''vehicle:''' {{RageType|number}}
*'''vehicle:''' {{RageType|number}} - The vehicle handle to check against.
*'''atGetIn:''' {{RageType|boolean}}
*'''atGetIn:''' {{RageType|boolean}} - Set `true` to include checking if the ped is getting into the vehicle; otherwise, only checks if the ped is fully inside.


===Return value===
=== Return value ===
*''' {{RageType|boolean}} '''
*''' {{RageType|boolean}} ''' - Returns `true` if the ped is in the vehicle (or entering it if `atGetIn` is `true`); otherwise, `false`.


==Syntax==
== Syntax ==
<syntaxhighlight lang="javascript">
<syntaxhighlight lang="javascript">
mp.game.ped.isInVehicle(ped, vehicle, atGetIn)
mp.game.ped.isInVehicle(ped, vehicle, atGetIn)
</syntaxhighlight>
</syntaxhighlight>


==Example==
== Example ==
<syntaxhighlight lang="javascript">
<syntaxhighlight lang="javascript">
//todo
// Check if a pedestrian is in or entering a specific vehicle
const ped = mp.players.local.handle;
const vehicle = mp.vehicles.at(0).handle;
if (mp.game.ped.isInVehicle(ped, vehicle, true)) {
    mp.gui.chat.push("Pedestrian is in or entering the vehicle.");
} else {
    mp.gui.chat.push("Pedestrian is not in the vehicle.");
}
</syntaxhighlight>
</syntaxhighlight>
}}
}}
==See also==
== See also ==
{{Ped_s_function_c}}
{{Ped_s_function_c}}
[[Category:Clientside API]]
[[Category:Clientside API]]
[[Category:TODO: Example]]
[[Category:TODO: Example]]

Latest revision as of 14:10, 3 November 2024

Client-Side
Function

 JavaScript



JavaScript Syntax


Description

This function checks if a specified pedestrian (ped) is currently inside a given vehicle. It can also check if the ped is in the process of entering the vehicle, depending on the value of `atGetIn`. This function is helpful for determining when a character is in or near entering a specific vehicle, allowing for additional gameplay logic to be applied.

Required Params

  • ped: number - The pedestrian handle to check.
  • vehicle: number - The vehicle handle to check against.
  • atGetIn: boolean - Set `true` to include checking if the ped is getting into the vehicle; otherwise, only checks if the ped is fully inside.

Return value

  • boolean - Returns `true` if the ped is in the vehicle (or entering it if `atGetIn` is `true`); otherwise, `false`.

Syntax

mp.game.ped.isInVehicle(ped, vehicle, atGetIn)

Example

// Check if a pedestrian is in or entering a specific vehicle
const ped = mp.players.local.handle;
const vehicle = mp.vehicles.at(0).handle;
if (mp.game.ped.isInVehicle(ped, vehicle, true)) {
    mp.gui.chat.push("Pedestrian is in or entering the vehicle.");
} else {
    mp.gui.chat.push("Pedestrian is not in the vehicle.");
}


See also