OnClientFileDownloadComplete: Difference between revisions

From Multi Theft Auto: Wiki
Jump to navigation Jump to search
No edit summary
No edit summary
Line 3: Line 3:
__NOTOC__  
__NOTOC__  
This event is triggered when a file has been downloaded after [[downloadFile]] has been successfully called.
This event is triggered when a file has been downloaded after [[downloadFile]] has been successfully called.
 
}}
==Parameters==  
==Parameters==  
<syntaxhighlight lang="lua">
<syntaxhighlight lang="lua">
Line 33: Line 33:
addEventHandler ( "onClientFileDownloadComplete", getRootElement(), onDownloadFinish )
addEventHandler ( "onClientFileDownloadComplete", getRootElement(), onDownloadFinish )
</syntaxhighlight>
</syntaxhighlight>
}}
 
==See Also==
==See Also==
===Other client events===
===Other client events===

Revision as of 06:22, 10 May 2012

This event is triggered when a file has been downloaded after downloadFile has been successfully called.

Parameters

string fileName, bool success
  • fileName: the file downloaded.
  • success: whether successful or not.

Source

The source of this event is the root element of the resource that called downloadFile.

Example

This example plays a sound if it was downloaded successfully

function onDownloadFinish ( file, success )
    if ( source == resourceRoot ) then                            -- if the file relates to this resource
        if ( success ) then                                       -- if the file was downloaded successfully
            if ( file == "test.mp3" ) then                        -- if the file name is what we were expecting
                currentTrack = playSound ( "test.mp3" )
            end
        else                                                      -- if the file wasn't downloaded successfully
            if ( file == "test.mp3" ) then
                outputChatBox ( "test.mp3 failed to download" )
            end
        end
    end
end
addEventHandler ( "onClientFileDownloadComplete", getRootElement(), onDownloadFinish )

See Also

Other client events


Client event functions