DownloadFile: Difference between revisions

From Multi Theft Auto: Wiki
Jump to navigation Jump to search
(Undo revision 29959 by Erdem kilic (talk))
No edit summary
Line 1: Line 1:
{{Client function}}
{{Client function}}
__NOTOC__
__NOTOC__
{{New items|3.0151|1.4|
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.
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.


Line 23: Line 24:
addEventHandler ( "onClientResourceStart", getRootElement(), onStart )
addEventHandler ( "onClientResourceStart", getRootElement(), onStart )
</syntaxhighlight>
</syntaxhighlight>
 
}}
==See Also==
==See Also==
{{Client_utility_functions}}
{{Client_utility_functions}}

Revision as of 06:08, 9 May 2012

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 resource has started.

-- the function is called, since the local player never changes)
function onStart ( )
    downloadFile ( "test.txt" )
end
addEventHandler ( "onClientResourceStart", getRootElement(), onStart )

See Also