DownloadFile

From Multi Theft Auto: Wiki
Revision as of 23:34, 22 September 2012 by FabioGNR (talk | contribs) (→‎Example)
Jump to navigation Jump to search

This function downloads a file from the HTTP server. This can only be used on files on the HTTP server associated with the MTA server and will only download files from within the folder of the resource that is calling it. The file should also be included in meta.xml with the download attribute set to "false", see meta.xml for more details. If the file has been previously downloaded and the CRC matches, the file will not be downloaded again but onClientFileDownloadComplete will still run.

Syntax

bool downloadFile ( string fileName )

Required Arguments

  • fileName: A string referencing the name of the file to download

Returns

Returns true if file download has been queued, false otherwise.

Example

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.txt" )
end
addEventHandler ( "onClientResourceStart", resourceRoot, onThisResourceStart )

See Also