OnClientFileDownloadComplete: Difference between revisions
Jump to navigation
Jump to search
OpenIDUser34 (talk | contribs) No edit summary |
OpenIDUser34 (talk | contribs) No edit summary |
||
| Line 5: | Line 5: | ||
<syntaxhighlight lang="lua"> | <syntaxhighlight lang="lua"> | ||
currentTrack = nil | |||
function onStart ( ) | function onStart ( ) | ||
downloadFile ( "test.mp3" ) | downloadFile ( "test.mp3" ) | ||
end | end | ||
| Line 14: | Line 14: | ||
if ( success ) then | if ( success ) then | ||
if ( file == "test.mp3" ) then | if ( file == "test.mp3" ) then | ||
currentTrack = playSound ( "test.mp3" ) | |||
end | end | ||
else | else | ||
| Line 25: | Line 23: | ||
end | end | ||
addEventHandler ( "onClientFileDownloadComplete", getRootElement(), onDownloadFinish ) | 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 ) | |||
</syntaxhighlight> | </syntaxhighlight> | ||
Revision as of 22:07, 22 February 2012
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