User talk:TheNormalnij: Difference between revisions

From Multi Theft Auto: Wiki
Jump to navigation Jump to search
(Blanked the page)
Tag: Blanking
 
Line 1: Line 1:
{{Client event}}
{{New items|3.0140|1.4|
__NOTOC__
This event is triggered when a file has been downloaded after [[downloadFile]] has been successfully called.
}}
==Parameters==
<syntaxhighlight lang="lua">
string fileName, bool success, resource requestResource
</syntaxhighlight>


*'''fileName''': the file downloaded.
*'''success''': whether successful or not.
{{New items|4.0153|1.5.7-20468|
*'''requestResource''': the resource that called [[downloadFile]].
}}
==Source==
The [[event system#Event source|source]] of this event is the [[root element]] of the resource that downloaded file.
==Example==
This example plays a sound if it was downloaded successfully
<syntaxhighlight lang="lua">
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", root, onDownloadFinish )
</syntaxhighlight>
==See Also==
===Other client events===
{{Client_other_events}}
===Client event functions===
{{Client_event_functions}}

Latest revision as of 12:41, 15 July 2020