Stevenn Posted April 7, 2012 Share Posted April 7, 2012 hey i want to play a sound when i start the resource, not when a player login or connect only when i restart/start resource function soundPlay() sound = playSound ("files/mission.mp3",false) setSoundVolume(sound, 1.0) end addEventHandler("onClientResourceStart", root, soundPlay) thanks! Link to comment
Castillo Posted April 7, 2012 Share Posted April 7, 2012 function soundPlay ( ) sound = playSound ("files/mission.mp3", false ) setSoundVolume ( sound, 1.0 ) end addEventHandler ( "onClientResourceStart", resourceRoot, soundPlay ) Link to comment
Stevenn Posted April 7, 2012 Author Share Posted April 7, 2012 function soundPlay ( ) sound = playSound ("files/mission.mp3", false ) setSoundVolume ( sound, 1.0 ) end addEventHandler ( "onClientResourceStart", resourceRoot, soundPlay ) Yea, i've tried that, the sound is still playing if i reconnect.. Link to comment
Castillo Posted April 7, 2012 Share Posted April 7, 2012 That's because every time you join, you download the client side resources and that triggers "onClientResourceStart". Link to comment
Stevenn Posted April 7, 2012 Author Share Posted April 7, 2012 That's because every time you join, you download the client side resources and that triggers "onClientResourceStart". oh, is it possible to not make it trigger? Link to comment
Jaysds1 Posted April 7, 2012 Share Posted April 7, 2012 (edited) That's because every time you join, you download the client side resources and that triggers "onClientResourceStart". oh, is it possible to not make it trigger? try this: addEventHandler ( "onClientPlayerJoin", root,function( ) sound = playSound ("files/mission.mp3", false ) setSoundVolume ( sound, 1.0 ) end) Edited April 7, 2012 by Guest Link to comment
Stevenn Posted April 7, 2012 Author Share Posted April 7, 2012 That's because every time you join, you download the client side resources and that triggers "onClientResourceStart". oh, is it possible to not make it trigger? try this: addEventHandler ( "onClientPlayerJoin", root,function( ) sound = playSound ("files/mission.mp3", false ) setSoundVolume ( sound, 1.0 ) end) wouldn't that specifically play the sound when i join? i want it to only play when i restart the resource. Link to comment
Jaysds1 Posted April 7, 2012 Share Posted April 7, 2012 wouldn't that specifically play the sound when i join? i want it to only play when i restart the resource. oh, srry, you could only use it for when the resource start/stop. Link to comment
Stevenn Posted April 7, 2012 Author Share Posted April 7, 2012 okay, but is it possible to bind the sound into a comamnand? Link to comment
Smart. Posted April 7, 2012 Share Posted April 7, 2012 (edited) function soundPlay ( command ) sound = playSound ( "files/mission.mp3", false ) setSoundVolume ( sound, 1.0 ) end addCommandHandler ( "sound", soundPlay ) -- change the command into whatever you want. Edited April 8, 2012 by Guest Link to comment
Castillo Posted April 7, 2012 Share Posted April 7, 2012 function soundPlay ( command ) -- Command handlers client side has no player argument. sound = playSound ( "files/mission.mp3", false ) setSoundVolume ( sound, 1.0 ) end addCommandHandler ( "sound", soundPlay ) -- change the command into whatever you want. Link to comment
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now