Ped::isHangingOnToVehicle: Difference between revisions

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


===Explanation===
The `isHangingOnToVehicle` function checks if a specified pedestrian (`ped`) is currently hanging onto a vehicle. This function can be useful for gameplay scenarios where you want to monitor a character's state, such as triggering events if the character is hanging onto a moving vehicle.


===Required Params===
===Required Params===
*'''ped:''' {{RageType|number}}
*'''ped:''' {{RageType|number}} — The handle of the pedestrian you want to check.


===Return value===
===Return value===
*''' {{RageType|boolean}} '''
*'''{{RageType|boolean}}''' — Returns `true` if the pedestrian is hanging onto a vehicle; otherwise, `false`.


==Syntax==
==Syntax==
Line 16: Line 17:


==Example==
==Example==
This example checks if the player character is hanging onto a vehicle. If so, it triggers a warning and plays an alert sound.
<syntaxhighlight lang="javascript">
<syntaxhighlight lang="javascript">
//todo
// Assume 'playerPed' is the player's ped handle
const playerPed = mp.players.local.handle;
 
// Check if the player is hanging onto a vehicle
if (mp.game.ped.isHangingOnToVehicle(playerPed)) {
    console.log("Warning: You are hanging onto a vehicle!");
   
    // Play a warning sound (hypothetical example)
    mp.game.audio.playSoundFrontend(-1, "Warning", "DLC_HEISTS_GENERAL_FRONTEND_SOUNDS", true);
}
</syntaxhighlight>
</syntaxhighlight>
}}
}}

Latest revision as of 19:04, 8 November 2024

Client-Side
Function

 JavaScript



JavaScript Syntax


Explanation

The `isHangingOnToVehicle` function checks if a specified pedestrian (`ped`) is currently hanging onto a vehicle. This function can be useful for gameplay scenarios where you want to monitor a character's state, such as triggering events if the character is hanging onto a moving vehicle.

Required Params

  • ped: number — The handle of the pedestrian you want to check.

Return value

  • 'boolean' — Returns `true` if the pedestrian is hanging onto a vehicle; otherwise, `false`.

Syntax

mp.game.ped.isHangingOnToVehicle(ped)

Example

This example checks if the player character is hanging onto a vehicle. If so, it triggers a warning and plays an alert sound.

// Assume 'playerPed' is the player's ped handle
const playerPed = mp.players.local.handle;

// Check if the player is hanging onto a vehicle
if (mp.game.ped.isHangingOnToVehicle(playerPed)) {
    console.log("Warning: You are hanging onto a vehicle!");
    
    // Play a warning sound (hypothetical example)
    mp.game.audio.playSoundFrontend(-1, "Warning", "DLC_HEISTS_GENERAL_FRONTEND_SOUNDS", true);
}


See also