Audio::isPedRingtonePlaying: 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.audio.isPedRingtonePlaying(ped) </syntaxhighlight> ==Example== <syntaxhighlight lang="javascript"> //todo </syntaxhighlight> }} ==See also== {{Audio_s_function_c}} Category:Clientside API Category:TODO: Example")
 
No edit summary
 
(One intermediate revision by the same user not shown)
Line 1: Line 1:
{{ClientsideJsFunction}}
{{ClientsideJsFunction}}
{{JSContainer|
{{JSContainer|


===Required Params===
===Required Params===
*'''ped:''' {{RageType|number}}
*'''ped:''' {{RageType|number}} — The ID of the pedestrian (player character) to check if the ringtone is playing.


===Return value===
===Return value===
*''' {{RageType|boolean}} '''
*'''boolean''' — Returns true if the ringtone is currently playing for the specified pedestrian, otherwise returns false.


==Syntax==
==Syntax==
<syntaxhighlight lang="javascript">
<syntaxhighlight lang="javascript">
mp.game.audio.isPedRingtonePlaying(ped)
// Function to check if a ringtone is playing for the player
</syntaxhighlight>
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.");
    }
}


==Example==
// Bind the function to a key (for example, the "E" key)
<syntaxhighlight lang="javascript">
mp.keys.bind(69, false, function() { // 69 is the key code for "E"
//todo
    checkRingtoneStatus(); // Call the function to check ringtone status
});
</syntaxhighlight>
</syntaxhighlight>
}}
}}
==See also==
==See also==
{{Audio_s_function_c}}
{{Audio_functions_c}}
[[Category:Clientside API]]
[[Category:Clientside API]]
[[Category:TODO: Example]]
[[Category:TODO: Example]]

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