EngineSetAsynchronousLoading

From Multi Theft Auto: Wiki
Jump to navigation Jump to search

Accessories-text-editor.png Script Example Missing Function EngineSetAsynchronousLoading needs a script example, help out by writing one.

Before submitting check out Editing Guidelines Script Examples.


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 ) 

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

Click to collapse [-]
Client
addEventHandler("onClientResourceStart", resourceRoot, function()
	engineSetAsynchronousLoading ( true, true ) -- Enables the asynchronous loading and ignores the client's preferences.
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