Streaming::hasAnimDictLoaded: Difference between revisions

From RAGE Multiplayer Wiki
No edit summary
 
(2 intermediate revisions by 2 users not shown)
Line 1: Line 1:
__NOTOC__
{{ClientsideJsFunction}}
Checks to see if the animation dictionary has loaded.


{{JSContainer|
==Syntax==
==Syntax==
<syntaxhighlight lang="javascript">mp.game.streaming.hasAnimDictLoaded(animDict);</syntaxhighlight>
<pre>
mp.game.streaming.hasAnimDictLoaded(animDict);
</pre>
 
=== Required Arguments ===
=== Required Arguments ===
*'''animDict:''' String
*'''animDict:''' {{RageType|String}}
 
===Return value===
===Return value===
*'''Boolean'''
*'''Boolean'''
==Example #1==  
==Example #1==  
This example will output notification with specified message.
{{ClientsideCode|
<pre>
async function loadLuckyWheelAnimLib(){
    if(mp.players.local.model === mp.game.joaat("mp_m_freemode_01")){
        animationLib = "anim_casino_a@amb@casino@games@lucky7wheel@male"
    } else if(mp.players.local.model === mp.game.joaat("mp_f_freemode_01")) {
        animationLib = "anim_casino_a@amb@casino@games@lucky7wheel@female"
    } else {
        return mp.gui.chat.push("You must be using a freemode character model");
    }
 
    mp.game.streaming.requestAnimDict(animationLib);
 
    // Used so you don't get stuck in an infinite loop if it never loads.
    for(let i = 0; mp.game.streaming.hasAnimDictLoaded(animationLib) === 0 && i < 15; i++){
        if(i === 14) return mp.game.graphics.notify('~r~Error loading Lucky Wheel spin animation.');
        mp.gui.chat.push("Loading wheel spin animation...");
        await mp.game.waitAsync(100);
    }


<div class="header" style="background-color: #408DAE; color: #FFFFFF; border: 2px solid #408DAE;">
    mp.gui.chat.push("Anim loaded.");
<div style="margin: 10px 10px 10px 10px;"><b>Client-Side</b></div>
}
<syntaxhighlight lang="javascript" highlight="4">
</pre>
mp.game.streaming.requestAnimDict("amb@code_human_cower@male@base");
}}
new Promise((resolve, reject) => {
}}
const timer = setInterval(() => {
if(mp.game.streaming.hasAnimDictLoaded("amb@code_human_cower@male@base")) {
clearInterval(timer);
resolve();
}
}, 100);
});
</syntaxhighlight>
</div>


==See also==
==See also==
{{Streaming_s_function_c}}
{{Streaming_functions_c}}
[[Category:Clientside API]]
[[Category:Clientside API]]
[[Category:TODO: Example]]

Latest revision as of 01:47, 25 April 2021

Client-Side
Function

 JavaScript



Checks to see if the animation dictionary has loaded.

JavaScript Syntax

Syntax

mp.game.streaming.hasAnimDictLoaded(animDict);

Required Arguments

  • animDict: String

Return value

  • Boolean

Example #1

Client-Side
async function loadLuckyWheelAnimLib(){
    if(mp.players.local.model === mp.game.joaat("mp_m_freemode_01")){
        animationLib = "anim_casino_a@amb@casino@games@lucky7wheel@male"
    } else if(mp.players.local.model === mp.game.joaat("mp_f_freemode_01")) {
        animationLib = "anim_casino_a@amb@casino@games@lucky7wheel@female"
    } else {
        return mp.gui.chat.push("You must be using a freemode character model");
    }

    mp.game.streaming.requestAnimDict(animationLib);

    // Used so you don't get stuck in an infinite loop if it never loads.
    for(let i = 0; mp.game.streaming.hasAnimDictLoaded(animationLib) === 0 && i < 15; i++){
        if(i === 14) return mp.game.graphics.notify('~r~Error loading Lucky Wheel spin animation.');
        mp.gui.chat.push("Loading wheel spin animation...");
        await mp.game.waitAsync(100);
    }

    mp.gui.chat.push("Anim loaded.");
}


See also