Stevenn Posted April 7, 2012 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!
Castillo Posted April 7, 2012 Posted April 7, 2012 function soundPlay ( ) sound = playSound ("files/mission.mp3", false ) setSoundVolume ( sound, 1.0 ) end addEventHandler ( "onClientResourceStart", resourceRoot, soundPlay )
Stevenn Posted April 7, 2012 Author 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..
Castillo Posted April 7, 2012 Posted April 7, 2012 That's because every time you join, you download the client side resources and that triggers "onClientResourceStart".
Stevenn Posted April 7, 2012 Author 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?
Jaysds1 Posted April 7, 2012 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
Stevenn Posted April 7, 2012 Author 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.
Jaysds1 Posted April 7, 2012 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.
Stevenn Posted April 7, 2012 Author Posted April 7, 2012 okay, but is it possible to bind the sound into a comamnand?
Smart. Posted April 7, 2012 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
Castillo Posted April 7, 2012 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.
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