Globals::waitAsync: Difference between revisions
MrPancakers2 (talk | contribs) (Created page with "__NOTOC__ {{ClientsideJsFunction}} An asynchronous function that pauses execution of your current script. {{JSContainer| == Syntax == <pre> mp.game.wait(ms); </pre> === Par...") |
No edit summary |
||
| Line 7: | Line 7: | ||
<pre> | <pre> | ||
mp.game. | mp.game.waitAsync(ms); | ||
</pre> | </pre> | ||
| Line 14: | Line 14: | ||
== Examples == | == Examples == | ||
Requests the specified scaleform, waits until it is loaded then returns the scaleform handle. | |||
{{ClientsideCode| | |||
<pre> | <pre> | ||
async function requestScaleform(scaleformName) { | |||
while ( | const handle = mp.game.graphics.requestScaleformMovie(scaleformName); | ||
while (!mp.game.graphics.hasScaleformMovieLoaded(handle)) { | |||
await mp.game.waitAsync(0); | |||
} | |||
return handle; | |||
} | |||
</pre> | </pre> | ||
}} | |||
}} | }} | ||
== See Also == | == See Also == | ||
{{GameGlobals}} | {{GameGlobals}} | ||
Latest revision as of 06:37, 18 August 2020
Client-Side Function
An asynchronous function that pauses execution of your current script.
JavaScript Syntax
Syntax
mp.game.waitAsync(ms);
Parameters
- ms: Int
Examples
Requests the specified scaleform, waits until it is loaded then returns the scaleform handle.
Client-Side
async function requestScaleform(scaleformName) {
const handle = mp.game.graphics.requestScaleformMovie(scaleformName);
while (!mp.game.graphics.hasScaleformMovieLoaded(handle)) {
await mp.game.waitAsync(0);
}
return handle;
}