Starkz Posted January 16, 2014 Posted January 16, 2014 Hi, I'm a real newbie in LUA script, and doing "something", I checked it but it doesn't work. The idea is to play a song (Which is played) and then pressing "space", the song stops. addEventHandler("onClientResourceStart", getResourceRootElement(getThisResource()), function() setTimer(function() playSound("winsound.mp3") end, 2000, 1) end ) function stopMusic(player, key, keyState) if(keyState == "down") then stopSound("winsound.mp3") end end function bindTheKeys(player, commandName) bindKey(player, "space", "down", stopMusic) end
Castillo Posted January 16, 2014 Posted January 16, 2014 The problem is that "bindTheKeys" function is never executed. Also, bindKey client side has no player argument. addEventHandler ( "onClientResourceStart", resourceRoot, function ( ) setTimer ( function ( ) sound = playSound ( "winsound.mp3" ) bindKey ( "space", "down", stopMusic ) end ,2000, 1 ) end ) function stopMusic ( key, keyState ) if ( keyState == "down" ) then stopSound ( sound ) end end San Andreas Utopia RPG (SAUR) Owner & Developer. Education is the most powerful weapon which you can use to change the world.
Starkz Posted January 16, 2014 Author Posted January 16, 2014 Still not working. The song sounds, but i cant stop it.
DNL291 Posted January 16, 2014 Posted January 16, 2014 addEventHandler("onClientResourceStart", resourceRoot, function() setTimer(function() sound = playSound("winsound.mp3") bindKey("space", "down", stopMusic) end, 2000, 1) end ) function stopMusic(key, keyState) if(keyState == "down") then stopSound(sound) end end Please do not PM me with scripting related question nor support, use the forums instead.
DNL291 Posted January 16, 2014 Posted January 16, 2014 You're welcome. Please do not PM me with scripting related question nor support, use the forums instead.
Castillo Posted January 16, 2014 Posted January 16, 2014 My mistake, I didn't notice that error. San Andreas Utopia RPG (SAUR) Owner & Developer. Education is the most powerful weapon which you can use to change the world.
Starkz Posted January 16, 2014 Author Posted January 16, 2014 Hey I have another cuestion. Is there a way to make the music gradually lower when it ends?
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