Streaming::requestAnimDict: Difference between revisions

From RAGE Multiplayer Wiki
m (Adds description about preloading animations)
No edit summary
 
(One intermediate revision by one other user not shown)
Line 1: Line 1:
This function is required when using client-side animations, you should preload the anim dictionary before using it, otherwise the animation won't work.  
__NOTOC__
{{ClientsideJsFunction}}
Requests and loads the animation dictionary required to play an animation.  


{{JSContainer|
==Syntax==
==Syntax==
<syntaxhighlight lang="javascript">mp.game.streaming.requestAnimDict(animDict);</syntaxhighlight>
 
<pre>
mp.game.streaming.requestAnimDict(animDict);
</pre>
 
=== Required Arguments ===
=== Required Arguments ===
*'''animDict:''' String
*'''animDict:''' {{RageType|String}}
===Return value===
 
*'''Undefined'''
==Example==
==Example==
<syntaxhighlight lang="javascript">
A function to load the animation dictionary used for the lucky wheel spin animations.
// todo
{{ClientsideCode|
</syntaxhighlight>
<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);
 
    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.")
}
</pre>
}}
}}
 
==See also==
==See also==
{{Streaming_s_function_c}}
{{Streaming_functions_c}}
 
[[Category:Clientside API]]
[[Category:Clientside API]]
[[Category:TODO: Example]]
[[Category:Client-side Function]]

Latest revision as of 01:51, 25 April 2021

Client-Side
Function

 JavaScript



Requests and loads the animation dictionary required to play an animation.

JavaScript Syntax

Syntax

mp.game.streaming.requestAnimDict(animDict);

Required Arguments

  • animDict: String

Example

A function to load the animation dictionary used for the lucky wheel spin animations.

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);

    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