EngineSetAsynchronousLoading: Difference between revisions
No edit summary |
|||
(4 intermediate revisions by 3 users not shown) | |||
Line 1: | Line 1: | ||
{{Client function}} | {{Client function}} | ||
__NOTOC__ | __NOTOC__ | ||
This function enables or disables asynchronous model loading. Enabling asynchronous model loading may reduce the small pauses that occur when a new model is displayed for the first time. However, it can cause the new models to appear slightly later than they might have otherwise. | This function enables or disables asynchronous model loading. Enabling asynchronous model loading may reduce the small pauses that occur when a new model is displayed for the first time. However, it can cause the new models to appear slightly later than they might have otherwise. | ||
{{Warning|Using this function with a large amounts of engineReplace* at the same time may cause loading times to be exponentially slower.}} | |||
==Syntax== | ==Syntax== | ||
Line 8: | Line 8: | ||
bool engineSetAsynchronousLoading ( bool enable, bool force ) | bool engineSetAsynchronousLoading ( bool enable, bool force ) | ||
</syntaxhighlight> | </syntaxhighlight> | ||
{{OOP||Engine.setAsynchronousLoading}} | |||
===Required Arguments=== | ===Required Arguments=== | ||
*'''enable:''' Set to true/false to enable/disable asynchronous loading. Only works if the client's preferences has 'Asynchronous Loading' set to 'Auto' | *'''enable:''' Set to true/false to enable/disable asynchronous loading. Only works if the client's preferences has 'Asynchronous Loading' set to 'Auto'. | ||
*'''force:''' If set to true, ignores the client's preferences. | *'''force:''' If set to true, ignores the client's preferences. | ||
Line 17: | Line 17: | ||
==Example== | ==Example== | ||
The next example enables the model asynchronous loading ignoring client preferences if there are a lot of objects (and the player wants to).<syntaxhighlight lang="lua"> | |||
<syntaxhighlight lang="lua"> | |||
addEventHandler("onClientResourceStart", resourceRoot, function() | addEventHandler("onClientResourceStart", resourceRoot, function() | ||
engineSetAsynchronousLoading ( true, | if #getElementsByType("object") > 500 then | ||
engineSetAsynchronousLoading( true, false ) | |||
end | |||
end) | end) | ||
</syntaxhighlight> | </syntaxhighlight> | ||
==How it works== | ==How it works== | ||
Line 30: | Line 30: | ||
Otherwise, all resource requests are queued up on the to-be-loaded queue. At the beginning of the game frame, the GTA:SA streaming system is updated, along with its streaming slicers. This is when a model is loaded after going through multiple stages. Having asynchronous loading disabled forces all stages to be consecutively run through. | Otherwise, all resource requests are queued up on the to-be-loaded queue. At the beginning of the game frame, the GTA:SA streaming system is updated, along with its streaming slicers. This is when a model is loaded after going through multiple stages. Having asynchronous loading disabled forces all stages to be consecutively run through. | ||
For more details read [[GTA:SA Resource Streaming]] | For more details read [[GTA:SA Resource Streaming]]. | ||
==See Also== | ==See Also== | ||
{{Engine_functions}} | {{Engine_functions}} |
Latest revision as of 20:11, 23 September 2021
This function enables or disables asynchronous model loading. Enabling asynchronous model loading may reduce the small pauses that occur when a new model is displayed for the first time. However, it can cause the new models to appear slightly later than they might have otherwise.
Syntax
bool engineSetAsynchronousLoading ( bool enable, bool force )
OOP Syntax Help! I don't understand this!
- Method: Engine.setAsynchronousLoading(...)
Required Arguments
- enable: Set to true/false to enable/disable asynchronous loading. Only works if the client's preferences has 'Asynchronous Loading' set to 'Auto'.
- force: If set to true, ignores the client's preferences.
Returns
Returns true if the function executed successfully, false otherwise.
Example
The next example enables the model asynchronous loading ignoring client preferences if there are a lot of objects (and the player wants to).
addEventHandler("onClientResourceStart", resourceRoot, function() if #getElementsByType("object") > 500 then engineSetAsynchronousLoading( true, false ) end end)
How it works
If asynchronous loading is disabled, MTA requests all resources to be loaded at the time they have been requested. This will halt game execution for the time being.
Otherwise, all resource requests are queued up on the to-be-loaded queue. At the beginning of the game frame, the GTA:SA streaming system is updated, along with its streaming slicers. This is when a model is loaded after going through multiple stages. Having asynchronous loading disabled forces all stages to be consecutively run through.
For more details read GTA:SA Resource Streaming.
See Also
- engineAddImage
- engineApplyShaderToWorldTexture
- engineFreeModel
- engineGetModelFlags
- engineGetModelIDFromName
- engineGetModelLODDistance
- engineGetModelNameFromID
- engineGetModelPhysicalPropertiesGroup
- engineGetModelTextureNames
- engineGetModelTextures
- engineGetModelTXDID
- engineGetModelVisibleTime
- engineGetObjectGroupPhysicalProperty
- engineGetSurfaceProperties
- engineGetVisibleTextureNames
- engineImageGetFilesCount
- engineImageGetFiles
- engineImageGetFile
- engineImageLinkDFF
- engineImageLinkTXD
- engineImportTXD
- engineLoadCOL
- engineLoadDFF
- engineLoadIMG
- engineLoadIFP
- engineLoadTXD
- engineRemoveImage
- engineRemoveShaderFromWorldTexture
- engineReplaceAnimation
- engineReplaceCOL
- engineReplaceModel
- engineRequestModel
- engineResetModelFlags
- engineResetModelLODDistance
- engineResetSurfaceProperties
- engineRestoreAnimation
- engineRestoreCOL
- engineRestoreDFFImage
- engineRestoreModel
- engineRestoreModelPhysicalPropertiesGroup
- engineRestoreObjectGroupPhysicalProperties
- engineRestoreTXDImage
- engineRestreamWorld
- engineSetAsynchronousLoading
- engineSetModelFlag
- engineSetModelFlags
- engineSetModelLODDistance
- engineSetModelPhysicalPropertiesGroup
- engineSetModelVisibleTime
- engineSetObjectGroupPhysicalProperty
- engineSetSurfaceProperties
- engineStreamingFreeUpMemory
- engineStreamingGetUsedMemory