Audio::isPedRingtonePlaying: Difference between revisions

From RAGE Multiplayer Wiki
No edit summary
No edit summary
 
Line 25: Line 25:
}
}


// Bind the function to a key (for example, the "L" key)
// Bind the function to a key (for example, the "E" key)
mp.keys.bind(76, false, function() { // 76 is the key code for "L"
mp.keys.bind(69, false, function() { // 69 is the key code for "E"
     checkRingtoneStatus(); // Call the function to check ringtone status
     checkRingtoneStatus(); // Call the function to check ringtone status
});
});

Latest revision as of 20:38, 6 October 2024

Client-Side
Function

 JavaScript



JavaScript Syntax


Required Params

  • ped: number — The ID of the pedestrian (player character) to check if the ringtone is playing.

Return value

  • boolean — Returns true if the ringtone is currently playing for the specified pedestrian, otherwise returns false.

Syntax

// Function to check if a ringtone is playing for the player
function checkRingtoneStatus() {
    let player = mp.players.local; // Reference to the local player

    // Check if a ringtone is playing for the player
    let isPlaying = mp.game.audio.isPedRingtonePlaying(player.handle);

    // Notify the player about the ringtone status
    if (isPlaying) {
        mp.gui.chat.push("A ringtone is currently playing.");
    } else {
        mp.gui.chat.push("No ringtone is currently playing.");
    }
}

// Bind the function to a key (for example, the "E" key)
mp.keys.bind(69, false, function() { // 69 is the key code for "E"
    checkRingtoneStatus(); // Call the function to check ringtone status
});


See also