OnClientFileDownloadComplete: Difference between revisions
Jump to navigation
Jump to search
OpenIDUser34 (talk | contribs) No edit summary |
m (Improved example) |
||
(11 intermediate revisions by 7 users not shown) | |||
Line 1: | Line 1: | ||
{{Client event}} | {{Client event}} | ||
{{New items|3.0140|1.4| | |||
__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"> | ||
string fileName, bool success | string fileName, bool success, resource requestResource | ||
</syntaxhighlight> | </syntaxhighlight> | ||
*'''fileName''': the file downloaded. | *'''fileName''': the file downloaded. | ||
*'''success''': whether successful or not. | *'''success''': whether successful or not. | ||
{{New items|4.0157|1.5.7-20468| | |||
*'''requestResource''': the resource that called [[downloadFile]]. | |||
}} | |||
==Source== | ==Source== | ||
The [[event system#Event source|source]] of this event is the [[root element]] of the resource that | The [[event system#Event source|source]] of this event is the [[root element]] of the resource that downloaded file. | ||
==Example== | ==Example== | ||
This example plays a sound if it was downloaded successfully | This example plays a sound if it was downloaded successfully | ||
<syntaxhighlight lang="lua"> | <syntaxhighlight lang="lua"> | ||
function | addEventHandler("onClientFileDownloadComplete", root, function(file, success) | ||
-- if the file relates to other resource | |||
if source ~= resourceRoot then | |||
return | |||
end | |||
-- if the file download failed | |||
if not success then | |||
outputChatBox(file..' failed to download') | |||
return | |||
end | |||
-- check if filename ends with .mp3 | |||
if file:sub(-4) ~= '.mp3' then | |||
return | |||
end | |||
-- if so, play the sound | |||
playSound(file) | |||
end) | |||
</syntaxhighlight> | </syntaxhighlight> | ||
Latest revision as of 14:36, 21 May 2024
This event is triggered when a file has been downloaded after downloadFile has been successfully called.
Parameters
string fileName, bool success, resource requestResource
- fileName: the file downloaded.
- success: whether successful or not.
Source
The 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
addEventHandler("onClientFileDownloadComplete", root, function(file, success) -- if the file relates to other resource if source ~= resourceRoot then return end -- if the file download failed if not success then outputChatBox(file..' failed to download') return end -- check if filename ends with .mp3 if file:sub(-4) ~= '.mp3' then return end -- if so, play the sound playSound(file) end)
See Also
Other client events
- onClientChatMessage
- onClientConsole
- onClientDebugMessage
- onClientExplosion
- onClientFileDownloadComplete
- onClientHUDRender
- onClientMinimize
- onClientMTAFocusChange
- onClientPedsProcessed
- onClientPlayerNetworkStatus
- onClientPreRender
- onClientRender
- onClientRestore
- onClientTransferBoxProgressChange
- onClientTransferBoxVisibilityChange
- onClientWorldSound
Client event functions
- triggerLatentServerEvent
- triggerServerEvent
- Shared
- addEvent
- addEventHandler
- cancelEvent
- cancelLatentEvent
- getEventHandlers
- getLatentEventHandles
- getLatentEventStatus
- removeEventHandler
- triggerEvent
- wasEventCancelled