Ped::isHangingOnToVehicle

From RAGE Multiplayer Wiki
Revision as of 19:04, 8 November 2024 by Shr0x (talk | contribs)
(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)

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