- Documentation
- Client functions
- downloadFile
Function
downloadFile
Downloads a resource file marked in meta.xml as <file src="..." download="false"/> only when it is needed (e.g. a large music file). The result arrives in the onClientFileDownloadComplete event, always asynchronously, also when the file was already downloaded. ":resource/file" downloads another resource's file.
Syntax
bool downloadFile(string fileName)Arguments
fileNamestring- The file path.
Returns
true if the download started.
Example
addEventHandler("onClientFileDownloadComplete", resourceRoot, function(name, ok)
if ok and name == "muzyka/intro.mp3" then playSound(name) end
end)
downloadFile("muzyka/intro.mp3")
<meta>
<script src="client.lua" type="client" />
<file src="muzyka/intro.mp3" download="false" />
</meta>