downloadFile | Multi Theft Auto: Wiki Skip to content

downloadFile

Client-side
Server-side
Shared

This page is incomplete! Help wanted!

Please finish this page using the corresponding Old Wiki article.
Go to Contribution guidelines for more information.


This function ensures the requested resource file is correct and then triggers onClientFileDownloadComplete. If the file has been previously downloaded and the CRC matches, the file will not be downloaded again but onClientFileDownloadComplete will still run. The file should also be included in the resource meta.xml with the download attribute set to "false", see meta.xml for more details.

Note

This function may cause performance issues with client and/or server.

Tip

If you are only using downloadFile to download mod files after other resources, then do not use downloadFile , and instead set '-1' in the resource meta.xml

Tip

Avoid using fileExists before calling downloadFile . Always call downloadFile and handle the result in onClientFileDownloadComplete

Syntax

downloadFile ( )

Code Examples

client

Example 1:This client side event downloads a file when the current resource has started.

-- the function is called on resource start
function onThisResourceStart ( )
downloadFile ( "test.xml" )
end
addEventHandler ( "onClientResourceStart", resourceRoot, onThisResourceStart )