OnClientFileDownloadComplete
Jump to navigation
Jump to search
my test example until I get a chance to document properly
currentTrack = nil function onStart ( ) downloadFile ( "test.mp3" ) end addEventHandler ( "onClientResourceStart", getRootElement(), onStart ) function onDownloadFinish ( file, success ) if ( success ) then if ( file == "test.mp3" ) then currentTrack = playSound ( "test.mp3" ) end else if ( file == "test.mp3" ) then outputChatBox ( "test.mp3 failed to download" ) end end end addEventHandler ( "onClientFileDownloadComplete", getRootElement(), onDownloadFinish ) function onSoundStopped ( reason ) if ( source == currentTrack ) then if ( reason == "destroyed" ) then outputChatBox ( "sound destroyed" ) elseif ( reason == "finished" ) then outputChatBox ( "end of sound" ) elseif ( reason == "paused" ) then outputChatBox ( "sound paused" ) end end end addEventHandler ( "onClientSoundStopped", getRootElement(), onSoundStopped ) function onSoundStarted ( reason ) if ( source == currentTrack ) then if ( reason == "play" ) then outputChatBox ( "sound started" ) elseif ( reason == "resumed" ) then outputChatBox ( "sound resumed" ) end end end addEventHandler ( "onClientSoundStarted", getRootElement(), onSoundStarted ) function stopSoundFunction () stopSound ( currentTrack ) end addCommandHandler ( "stop1", stopSoundFunction ) function songPause() local pause = isSoundPaused ( currentTrack ) if ( pause == true ) then setSoundPaused ( currentTrack, false ) else setSoundPaused ( currentTrack, true ) end end addCommandHandler("pause", songPause) function startSoundFunction () currentTrack = playSound ( "test.mp3" ) end addCommandHandler ( "start1", startSoundFunction )
See Also
Other client events
- onClientChatMessage
- onClientConsole
- onClientDebugMessage
- onClientExplosion
- onClientFileDownloadComplete
- onClientHUDRender
- onClientMinimize
- onClientMTAFocusChange
- onClientPedsProcessed
- onClientPlayerNetworkStatus
- onClientPreRender
- onClientRender
- onClientRestore
- onClientTransferBoxProgressChange
- onClientTransferBoxVisibilityChange
- onClientWorldSound